Bug #81263 [NEW]: Wrong result from DateTimeImmutable::diff

From: Date: Thu, 15 Jul 2021 21:32:41 +0000
Subject: Bug #81263 [NEW]: Wrong result from DateTimeImmutable::diff
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235071@lists.php.net to get a copy of this message
From: mail at gh01 dot de Operating system: PHP version: master-Git-2021-07-15 (Git) Package: Date/time related Bug Type: Bug Bug description:Wrong result from DateTimeImmutable::diff Description: ------------ PHP 8.0 (correct): https://3v4l.org/Wofuu#v8.0.8 PHP 8.1 (wrong): https://3v4l.org/Wofuu/rfc#vgit.master Test script: --------------- <?php $dt1 = new DateTimeImmutable('2020-07-19 18:30:00', new DateTimeZone('Europe/Berlin')); $dt2 = new DateTimeImmutable('2020-07-19 16:30:00', new DateTimeZone('UTC')); print_r($dt1->diff($dt2)); Expected result: ---------------- DateInterval Object ( [y] => 0 [m] => 0 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [f] => 0 [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] => 24 [i] => 0 [s] => 0 [f] => 0 [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 bug report at https://bugs.php.net/bug.php?id=81263&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81263&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81263&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81263&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81263&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81263&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81263&r=support Expected behavior: https://bugs.php.net/fix.php?id=81263&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81263&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81263&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81263&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81263&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81263&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81263&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81263&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81263&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81263&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81263&r=mysqlcfg

« previous php.bugs (#235071) next »