[php-src] Issue #10643: DateTime->modify produces different results in php8.2 than in php8.1
| From: | samuelvi | Date: | Tue, 21 Feb 2023 11:03:27 +0000 |
| Subject: | [php-src] Issue #10643: DateTime->modify produces different results in php8.2 than in php8.1 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243762@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10643
Author: samuelvi
### Description
The following code:
```php
<?php
$dt = new DateTime('2015-01-01 00:00:00+00:00');
var_dump($dt->format('c'));
var_dump($dt->modify('+-2 days')->format('c'));
$dt = new DateTimeImmutable('2015-01-01 00:00:00+00:00');
var_dump($dt->format('c'));
var_dump($dt->modify('+-2 hours')->format('c'));
```
Resulted in this output:
```
string(25) "2015-01-01T00:00:00+00:00"
string(25) "2015-01-03T00:00:00+00:00"
string(25) "2015-01-01T00:00:00+00:00"
string(25) "2015-01-01T02:00:00+00:00"
```
But I expected this output instead:
```
string(25) "2015-01-01T00:00:00+00:00"
string(25) "2014-12-30T00:00:00+00:00"
string(25) "2015-01-01T00:00:00+00:00"
string(25) "2014-12-31T22:00:00+00:00"
```
### PHP Version
8.2.1
### Operating System
Gentoo Linux 2.9 - Ubuntu 22.04.2 LTS (Jammy Jellyfish)