[php-src] Issue #8730: DateTime::diff miscalculation is same time zone of different type

From: Date: Wed, 08 Jun 2022 13:36:25 +0000
Subject: [php-src] Issue #8730: DateTime::diff miscalculation is same time zone of different type
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241686@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8730 Author: jabelli ### Description Something appears amiss when DateTime::diff is used on two dates with different time zone types in DST Possibly related to [#81263](https://bugs.php.net/bug.php?id=81263) The following code: ```php <?php $foo = new DateTime('2022-06-08 09:15:00', new DateTimeZone('-04:00')); $bar = new DateTime('2022-06-08 09:15:00', new DateTimeZone('US/Eastern')); var_dump($foo->diff($bar)); ``` Resulted in this output: ```object(DateInterval)#3 (16) { ["y"]=> int(-1) ["m"]=> int(11) ["d"]=> int(30) ["h"]=> int(23) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(0) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } ``` But I expected this output instead: ```object(DateInterval)#3 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> int(0) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } ``` [Linky](https://3v4l.org/cJbjm) If you change the month to 01, you get the expected difference of 0. ### PHP Version PHP 8.1.6 ### Operating System Windows 10

« previous php.bugs (#241686) next »