[php-src] Issue #8260: Adding a DateInterval during switch to DST can result in incorrect times
| From: | timmipetit | Date: | Mon, 28 Mar 2022 08:49:25 +0000 |
| Subject: | [php-src] Issue #8260: Adding a DateInterval during switch to DST can result in incorrect times | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-240524@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8260
Author: timmipetit
### Description
Behaviour in PHP 8.1 is correct, but incorrect for PHP 8.0.17: https://3v4l.org/HQmqn
The following code:
```php
<?php
date_default_timezone_set('Europe/Amsterdam');
$baseDate = new DateTimeImmutable('2022-03-27 01:30:00');
echo $baseDate->add(new DateInterval('PT1H'))->format('Y-m-d H:i:s') .
PHP_EOL;
echo $baseDate->add(new DateInterval('PT2H'))->format('Y-m-d H:i:s') .
PHP_EOL;
echo $baseDate->add(new DateInterval('PT1H'))->add(new
DateInterval('PT1H'))->format('Y-m-d H:i:s') . PHP_EOL;
```
Resulted in this output:
```
2022-03-27 03:30:00
2022-03-27 03:30:00
2022-03-27 04:30:00
```
But I expected this output instead:
```
2022-03-27 03:30:00
2022-03-27 04:30:00
2022-03-27 04:30:00
```
### PHP Version
PHP 8.0.17
### Operating System
_No response_