Closed
Description
Description
The following code:
<?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