Bug #75855 [Opn->Nab]: DateTime::diff class does not take into account microseconds in some cases
| From: | derick@php.net | Date: | Tue, 06 Apr 2021 18:23:41 +0000 |
| Subject: | Bug #75855 [Opn->Nab]: DateTime::diff class does not take into account microseconds in some cases | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233236@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75855&edit=1
ID: 75855
Updated by: derick@php.net
Reported by: marcospassos dot com at gmail dot com
Summary: DateTime::diff class does not take into account
microseconds in some cases
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
PHP Version: 7.2.2RC1
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP --
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php
If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
Looks from the 3v4l link that that got fixed in 7.2.12 already.
Previous Comments:
------------------------------------------------------------------------
[2018-01-21 19:33:05] marcospassos dot com at gmail dot com
Description:
------------
The method DateTime::diff() of the native DateTime class does not take into account microseconds, as
explained below.
Start: 2015-08-31 00:00:00.000001
End: 2015-09-01 00:00:00.000000
The diff object returned by the method DateTime::diff() for these dates reports that a whole day has
been elapsed since the start date. As evidenced, such result is wrong since 1 microsecond is missing
in the interval to complete a full day.
In an addition, the result of the number of microseconds is expected to be positive, as all the
units do. However, in this case, the result is negative.
Test script:
---------------
https://3v4l.org/6INks
Expected result:
----------------
Years: 0
Days: 0
Total days: 0
Months: 0
Hours: 0
Minutes: 0
Seconds: 0
Microseconds: 1.0E-6
Actual result:
--------------
Years: 0
Days: 1
Total days: 1
Months: 0
Hours: 0
Minutes: 0
Seconds: 0
Microseconds: 1.0E-6
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75855&edit=1