Bug #77097 [NEW]: DateTime::diff gives wrong diff when the actual diff is less than 1 second
| From: | vishnunn at ymail dot com | Date: | Sat, 03 Nov 2018 11:59:17 +0000 |
| Subject: | Bug #77097 [NEW]: DateTime::diff gives wrong diff when the actual diff is less than 1 second | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217800@lists.php.net to get a copy of this message | ||
From: vishnunn at ymail dot com
Operating system: CentOS Linux 7.5.1804
PHP version: 7.3.0RC4
Package: Date/time related
Bug Type: Bug
Bug description:DateTime::diff gives wrong diff when the actual diff is less than 1 second
Description:
------------
---
From manual page: https://php.net/datetime.diff
---
Test script:
---------------
$now = new DateTime('2018-11-03 11:34:20.781751');
$ago = new DateTime('2018-11-03 11:34:20.000000');
$diff = $now->diff($ago);
var_dump($diff);
Expected result:
----------------
On PHPv7.2.11 it gives the correct output:
Date/time in $now: 2018-11-03 11:34:20.781751
Date/time in $ago: 2018-11-03 11:34:20.000000
object(DateInterval)#574 (16) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(-0.781751)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
Actual result:
--------------
On PHPv7.3RC4 it give this output which is wrong:
Date/time in $now: 2018-11-03 11:50:50.826351
Date/time in $ago: 2018-11-03 11:50:50.000000
object(DateInterval)#574 (16) {
["y"]=>
int(-1)
["m"]=>
int(11)
["d"]=>
int(30)
["h"]=>
int(23)
["i"]=>
int(59)
["s"]=>
int(59)
["f"]=>
float(0.173649)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(0)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
--
Edit bug report at https://bugs.php.net/bug.php?id=77097&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77097&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77097&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77097&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77097&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77097&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77097&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77097&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77097&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77097&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77097&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77097&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77097&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77097&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77097&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77097&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77097&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77097&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77097&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77097&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77097&r=mysqlcfg