|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74524 Date diff is bad calculated, in same time zone
Submitted: 2017-05-01 20:59 UTC Modified: 2017-05-06 19:02 UTC
Avg. Score:3.3 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: kalita dot michal at gmail dot com Assigned:
Status: Open Package: Date/time related
PHP Version: 7.1.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kalita dot michal at gmail dot com
New email:
PHP Version: OS:


 [2017-05-01 20:59 UTC] kalita dot michal at gmail dot com
Calculated diff is 7 months, 14 days and -1 hour.

It doen't make sense, why it is not 7 months, 13 days and 23 hours.

This bug is in versions 5.4.45, 5.6.30, 7 and newest. (

Test script:
$a = new DateTime("2017-11-17 22:05:26.000000");
$b = new DateTime("2017-04-03 22:29:15.079459");

$diff = $a->diff($b);

return $diff->h;

Expected result:

Actual result:


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-02 12:22 UTC] andrew dot nester dot dev at gmail dot com
thanks for reporting the issue!
I've been trying to reproduce it on latest PHP7.1 version (7.1.6-dev) and seems it's fixed already.
Anyway, I've added test to check that it works (see my PR)
 [2017-05-02 12:33 UTC]
Andrew, it might look fixed for you because you have a different timezone with different DST rules configured.
 [2017-05-02 20:06 UTC] andrew dot nester dot dev at gmail dot com
Thanks Derick!
gonna rework my pull request
 [2017-05-03 07:18 UTC] andrew dot nester dot dev at gmail dot com
Just added reworked pull request to this issue. Here is the link
 [2017-05-06 19:02 UTC]
This is a DST issue as can be seen in

The default Timezone of is Europe/Amsterdam which has DST and therefore has the issue!
 [2017-10-30 11:26 UTC] onda204 at gmail dot com
I detected the following issue that may have to do with present Bug.
Using diff with dates that are on range of summer / winter time change, the function diff on element $interval->h gives result -1

Tested width date interval:
15.00 H

14.00 H

Portuguese regional settings
 [2017-12-01 16:46 UTC] miloslav dot hula at gmail dot com
probably another example of bug:

In the Europe/Prague timezone, there was a 1 hour switch back on 29th Oct 2017 from 03:00 to 02:00 (from CEST to CET).

When run on with EOL versions checked, you can notice that behaviour has been correct in 5.3.0-5.4.23, 5.5.0-5.5.7. In the PHP5 5.4.24 and 5.5.8 change log is fixed bug #66060 (
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC