Bug #75855 [NEW]: DateTime::diff class does not take into account microseconds in some cases

From: Date: Sun, 21 Jan 2018 19:33:06 +0000
Subject: Bug #75855 [NEW]: DateTime::diff class does not take into account microseconds in some cases
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213646@lists.php.net to get a copy of this message
From: marcospassos dot com at gmail dot com Operating system: PHP version: 7.2.2RC1 Package: Date/time related Bug Type: Bug Bug description:DateTime::diff class does not take into account microseconds in some cases 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 bug report at https://bugs.php.net/bug.php?id=75855&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75855&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75855&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75855&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75855&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75855&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75855&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75855&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75855&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75855&r=support Expected behavior: https://bugs.php.net/fix.php?id=75855&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75855&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75855&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75855&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75855&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75855&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75855&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75855&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75855&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75855&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75855&r=mysqlcfg

« previous php.bugs (#213646) next »