Bug #77121 [Opn->Dup]: fractions in diff cause overflow in same second datetimes

From: Date: Thu, 08 Nov 2018 09:55:54 +0000
Subject: Bug #77121 [Opn->Dup]: fractions in diff cause overflow in same second datetimes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217865@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77121&edit=1 ID: 77121 Updated by: cmb@php.net Reported by: sakari dot laine at verkkokauppa dot com Summary: fractions in diff cause overflow in same second datetimes -Status: Open +Status: Duplicate Type: Bug Package: Date/time related Operating System: linux PHP Version: 7.2.12RC1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This looks like a duplicate of bug #77097. Previous Comments: ------------------------------------------------------------------------ [2018-11-08 08:55:44] sakari dot laine at verkkokauppa dot com Description: ------------ Datetime diff overflows if fractions and no fractions in same second. Test script: --------------- $date = new \DateTime('2018-11-08 10:22:43'); $date2 = new \DateTime('2018-11-08 10:22:43.123456'); print_r($date2->diff($date)); Expected result: ---------------- DateInterval Object ( [y] => 0 [m] => 0 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [f] => -0.123456 [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.876544 [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=77121&edit=1

« previous php.bugs (#217865) next »