Closed
Description
Description
The following code:
<?php
$dt1 = new DateTime('2022-08-01 07:00:00', new DateTimeZone('Europe/Berlin'));
$dt2 = new DateTime('2022-08-01 07:00:00 +02:00');
echo "DT1: {$dt1->format('c')}" . PHP_EOL;
echo "DT2: {$dt2->format('c')}" . PHP_EOL;
$diff = $dt1->diff($dt2);
echo "Diff: {$diff->format('%h')}";
Resulted in this output:
DT1: 2022-08-01T07:00:00+02:00
DT2: 2022-08-01T07:00:00+02:00
Diff: 1
But I expected this output instead:
DT1: 2022-08-01T07:00:00+02:00
DT2: 2022-08-01T07:00:00+02:00
Diff: 0
According to https://3v4l.org/eOUP5 this bug exists since PHP 8.1.0
PHP Version
PHP 8.1.9
Operating System
Fedora 36