[php-src] Issue #11029: DateTimeImmutable sub month produce wrong date
| From: | ushell | Date: | Fri, 07 Apr 2023 05:11:39 +0000 |
| Subject: | [php-src] Issue #11029: DateTimeImmutable sub month produce wrong date | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244135@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11029
Author: ushell
### Description
The following code:
```php
<?php
$date = new DateTimeImmutable('2023-03-29');
echo $date->modify('-1 month')->format('Y-m-d');
```
Resulted in this output:
```
2023-03-01
```
But I expected this output instead:
```
2023-02-28
```
```php
<?php
$date = new DateTimeImmutable('2023-04-29');
echo $date->modify('-1 month')->format('Y-m-d');
// output 2023-03-29 is right
```
### PHP Version
PHP 8.1.3
### Operating System
_No response_