Bug #77237 [Opn]: DateTime diff wrong when using milliseconds
Edit report at https://bugs.php.net/bug.php?id=77237&edit=1
ID: 77237
User updated by: bstanescu at gmail dot com
Reported by: bstanescu at gmail dot com
Summary: DateTime diff wrong when using milliseconds
Status: Open
Type: Bug
Package: Date/time related
Operating System: Ubuntu 16.0.4
PHP Version: 7.2.12
Block user comment: N
Private report: N
New Comment:
Edit:
Expected fraction is
[f] => -0.001
Not
[f] => -0.123
Previous Comments:
------------------------------------------------------------------------
[2018-12-04 08:43:44] bstanescu at gmail dot com
Description:
------------
DateTime diff method returns incorrect result when using milliseconds
This might be related to this fix introduced in 7.2.12:
https://bugs.php.net/bug.php?id=77007
Test script:
---------------
<?php
$diff = (new DateTime('2018-12-04T07:42:59.123Z'))->diff(new
DateTime('2018-12-04T07:42:59.122Z');
print_r($diff);
?>
Expected result:
----------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0
[f] => -0.123
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
Actual result:
--------------
DateInterval Object
(
[y] => -1
[m] => 11
[d] => 29
[h] => 23
[i] => 59
[s] => 59
[f] => 0.999
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77237&edit=1
Thread (3 messages)