[php-src] Issue #9880: DateTime diff returns wrong sign on day count when using a timezone (Regression)

From: Date: Wed, 02 Nov 2022 19:43:10 +0000
Subject: [php-src] Issue #9880: DateTime diff returns wrong sign on day count when using a timezone (Regression)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242737@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9880 Author: neildaniels ### Description The following code: https://3v4l.org/7biFY ```php <?php ini_set('date.timezone', 'America/Los_Angeles'); $nowTime = new DateTime(); $nowTime->setTimestamp(1667416695); $dateTime = new DateTime(); $dateTime->setTimestamp(1671904800); $dateTime->setTimezone(new DateTimeZone('America/New_York')); echo $dateTime->diff($nowTime)->format('%r%a'); ``` Resulted in this output: ``` 51 ``` But I expected this output instead: ``` -51 ``` This code works as expected _prior_ to 8.1.10. If you comment out the $dateTime->setTimezone(new DateTimeZone('America/New_York')); line, the code works as expected on all versions. ### PHP Version PHP 8.1.12 ### Operating System Alpine 3.16

« previous php.bugs (#242737) next »