|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77145 Inconsistent handle of negative interval lower than 1 second
Submitted: 2018-11-13 12:46 UTC Modified: 2018-11-13 13:42 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kylekatarnls at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Date/time related
PHP Version: 7.3.0RC5 OS:
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: kylekatarnls at gmail dot com
New email:
PHP Version: OS:


 [2018-11-13 12:46 UTC] kylekatarnls at gmail dot com
When calling DateTime::diff from (DateX) to (DateX - few microseconds), I get inconsistent intervals between versions and none are what I would expect (inverted interval with positive microseconds).

Test script:
$s = new DateTime('2018-10-11 20:59:06.914653');
$e = new DateTime('2018-10-11 20:59:06.237419');

echo $s->diff($e)->format('%R %Y-%M-%D %H:%I:%S.%F');

Expected result:
- 00-00-00 00:00:00.677234

Actual result:
Output for 7.3.0rc4 - 7.3.0rc5

+ -1-11-29 23:59:59.322766

Output for 7.1.0 - 7.3.0rc3

+ 00-00-00 00:00:00.-677234

As tested with

Note sure, but I guess 7.2.12 would looks like 7.3.0rc5 as it's probably consecutive to bugfix


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-13 13:42 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2018-11-13 13:42 UTC]
This looks like a duplicate of bug #77097.
 [2018-11-13 14:15 UTC] kylekatarnls at gmail dot com
Yes it may be the same.

I would add, if we pass $absolute = TRUE, we still get the negative result.
 [2018-12-05 09:28 UTC] daszwarc at olx dot pl
PHP 7.2.12 is also affected
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Apr 10 20:01:24 2021 UTC