Bug #77235 [Opn->Dup]: DateTime::diff Wrong result if subsecond difference

From: Date: Tue, 04 Dec 2018 09:50:34 +0000
Subject: Bug #77235 [Opn->Dup]: DateTime::diff Wrong result if subsecond difference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218264@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77235&edit=1 ID: 77235 Updated by: derick@php.net Reported by: arkham dot vm at gmail dot com Summary: DateTime::diff Wrong result if subsecond difference -Status: Open +Status: Duplicate Type: Bug Package: Date/time related Operating System: CentOs 7.5 PHP Version: 7.2.12 Block user comment: N Private report: N New Comment: Duplicate of #77097, which is already fixed. Previous Comments: ------------------------------------------------------------------------ [2018-12-04 06:30:22] arkham dot vm at gmail dot com Change package to "Date/time related" ------------------------------------------------------------------------ [2018-12-04 06:23:08] arkham dot vm at gmail dot com 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 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77235&edit=1

« previous php.bugs (#218264) next »