Open
Description
Description
In PHP 8.1.25, running date_diff against different time zones returned unexpected results.
The following code:
<?php
date_default_timezone_set('Asia/Tokyo');
$nowDate = (new DateTime('2024-04-01 00:49:22'))->setTimeZone(new DateTimeZone('Asia/Tokyo'));
$endDate = (new DateTime('2024-04-01 08:48:22'))->setTimeZone(new DateTimeZone('UTC'));
echo date_diff($nowDate, $endDate)->format('%Y-%M-%D %H:%I:%S');
Resulted in this output:
-1-11-31 07:59:00
But I expected this output instead:
00-00-00 07:59:00
PHP Version
PHP 8.1.25
Operating System
Ubuntu 22.04