Bug #77097 [Com]: DateTime::diff gives wrong diff when the actual diff is less than 1 second

From: Date: Thu, 22 Nov 2018 14:31:22 +0000
Subject: Bug #77097 [Com]: DateTime::diff gives wrong diff when the actual diff is less than 1 second
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218086@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77097&edit=1 ID: 77097 Comment by: wyatt at wyday dot com Reported by: vishnunn at ymail dot com Summary: DateTime::diff gives wrong diff when the actual diff is less than 1 second Status: Verified Type: Bug Package: Date/time related Operating System: CentOS Linux 7.5.1804 PHP Version: 7.3.0RC4 Assigned To: derick Block user comment: N Private report: N New Comment: We can confirm this bug exists on PHP 7.3.0 RC5 (for our development machines) and PHP 7.2.12 for our production machines. This is a showstopper for us. We've had to rollback to 7.2.11 on our production machines and we'll be unable to upgrade to any new version until this bug is fixed. It looks like it's related to the latest timelib upgrade. It looks like you should revert that change in the next version until all the edge cases are solved. Previous Comments: ------------------------------------------------------------------------ [2018-11-13 13:42:16] cmb@php.net Related To: Bug #77145 ------------------------------------------------------------------------ [2018-11-09 06:04:01] sakari dot laine at verkkokauppa dot com Affects also 7.2.12 ------------------------------------------------------------------------ [2018-11-08 09:55:53] cmb@php.net Related To: Bug #77121 ------------------------------------------------------------------------ [2018-11-03 12:21:15] cmb@php.net I can confirm a behavioral change, albeit I get a slightly different result with PHP-7.3 (@9afce01), where 'f' is float(0.218249). This would basically still be somehow correct, but if I request an $absolute result, I still get an identical result, which is certainly not correct. Derick, could you please have a look at this? ------------------------------------------------------------------------ [2018-11-03 11:59:17] vishnunn at ymail dot com 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 this bug report at https://bugs.php.net/bug.php?id=77097&edit=1

« previous php.bugs (#218086) next »