|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-12-04 06:30 UTC] arkham dot vm at gmail dot com
-Package: *General Issues
+Package: Date/time related
[2018-12-04 06:30 UTC] arkham dot vm at gmail dot com
[2018-12-04 09:50 UTC] derick@php.net
-Status: Open
+Status: Duplicate
[2018-12-04 09:50 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 05:00:01 2025 UTC |
Description: ------------ If diffirence between two dates less than second, `DateTime::diff` returns more than 1 year of difference. `date_diff` contains same bug. Works properly on: PHP 7.2.10-0ubuntu1 (cli) (built: Sep 13 2018 13:38:55) ( NTS ) Bugged on: PHP 7.2.12 (cli) (built: Nov 6 2018 16:40:25) ( NTS ) Test script: --------------- <?php $utc = new DateTimeZone('utc'); $foo = new DateTime('2018-11-29 07:14:12.503985', $utc); $bar = new DateTime('2018-11-29 07:14:12.000000', $utc); print_r($foo->diff($bar)); Expected result: ---------------- DateInterval Object ( [y] => 0 [m] => 0 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [f] => -0.503985 [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] => 30 [h] => 23 [i] => 59 [s] => 59 [f] => 0.496015 [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 )