Bug #66545 [Opn->Csd]: DateTime

From: Date: Tue, 06 Apr 2021 19:52:43 +0000
Subject: Bug #66545 [Opn->Csd]: DateTime
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233251@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66545&edit=1 ID: 66545 Updated by: derick@php.net Reported by: perrier dot p at gmail dot com Summary: DateTime -Status: Open +Status: Closed Type: Bug Package: Date/time related Operating System: Debian 7 PHP Version: 5.5.8 -Assigned To: +Assigned To: derick Block user comment: N Private report: N New Comment: The fix for this bug has been committed. If you are still experiencing this bug, try to check out latest source from https://github.com/php/php-src and re-test. Thank you for the report, and for helping us make PHP better. Fixed for PHP 8.1. Previous Comments: ------------------------------------------------------------------------ [2016-06-20 15:57:10] cmb@php.net > DateInterval fail to calculate number of days and hours Well, actually it does calculate the number of days and hours (14 days + 23 hours == 15 days - 1 hour), but obviously the values don't get normalized. Not sure if that's a bug or something to be documented. ------------------------------------------------------------------------ [2014-01-24 21:33:11] s dot wuerker at injc dot net I've got the same problem with the following code: http://3v4l.org/ekMU7 ------------------------------------------------------------------------ [2014-01-22 14:13:42] perrier dot p at gmail dot com Description: ------------ DateInterval fail to calculate number of days and hours http://3v4l.org/ab0Hm#v5424 Test script: --------------- <?php $debut = mktime(0, 0, 0, 10, 27, 2013); $fin = mktime(23, 59, 59, 11, 10, 2013); $d1 = new DateTime('now',new DateTimeZone('Europe/Paris')); $d2 = new DateTime('now',new DateTimeZone('Europe/Paris')); $d1->setTimestamp($debut); $d2->setTimestamp($fin); $diff = $d1->diff($d2); print_r($diff); Expected result: ---------------- DateInterval Object ( [y] => 0 [m] => 0 [d] => 14 [h] => 23 [i] => 59 [s] => 59 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 14 [special_type] => 0 [special_amount] => 0 [have_weekday_relative] => 0 [have_special_relative] => 0 ) Actual result: -------------- DateInterval Object ( [y] => 0 [m] => 0 [d] => 15 [h] => -1 [i] => 59 [s] => 59 [weekday] => 0 [weekday_behavior] => 0 [first_last_day_of] => 0 [invert] => 0 [days] => 14 [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=66545&edit=1

« previous php.bugs (#233251) next »