php.net |  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
Votes:1
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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kylekatarnls at gmail dot com
New email:
PHP Version: OS:

 

 [2018-11-13 12:46 UTC] kylekatarnls at gmail dot com
Description:
------------
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 https://3v4l.org/hnnL0

Note sure, but I guess 7.2.12 would looks like 7.3.0rc5 as it's probably consecutive to https://bugs.php.net/bug.php?id=77007 bugfix

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-13 13:42 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2018-11-13 13:42 UTC] cmb@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC