[php-src] Issue #9454: DateTime::modify('-1 month') returnt wrong value
| From: | ELWAHAB | Date: | Wed, 31 Aug 2022 09:21:48 +0000 |
| Subject: | [php-src] Issue #9454: DateTime::modify('-1 month') returnt wrong value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242344@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9454
Author: ELWAHAB
### Description
The following code:
```php
<?php
$datetime = new \DateTime('2022-07-31 00:00:00');
var_export($datetime->format('Y-m-d H:i:s'));
$datetime->modify('-1 month');
echo PHP_EOL;
var_export($datetime->format('Y-m-d H:i:s'));
```
Resulted in this output:
```
'2022-07-31 00:00:00'
'2022-07-01 00:00:00'
```
But I expected this output instead:
```
'2022-07-31 00:00:00'
'2022-06-30 00:00:00'
```
### PHP Version
PHP 8.1.6
### Operating System
Debian GNU/Linux 11