[php-src] Issue #10045: DateTime::modify 'this monday' returns incorrect value for 2022-11-01
| From: | sergbass | Date: | Sat, 03 Dec 2022 09:54:26 +0000 |
| Subject: | [php-src] Issue #10045: DateTime::modify 'this monday' returns incorrect value for 2022-11-01 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243041@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10045
Author: sergbass
### Description
The following code:
```php
<?php
// 2022-11-01 is Tuesday
echo (new \DateTime('2022-11-01'))->modify('this
monday')->format('Y-m-d');
```
Resulted in this output:
```
2022-11-07
```
But I expected this output instead:
```
2022-10-31
```
So, it actually returns next Monday instead of this Monday in this particular case. But following
code works properly as a temporary workaround:
```php
<?php
echo (new \DateTime('2022-11-01'))->modify('next
monday')->modify('last monday')->format('Y-m-d');
```
### PHP Version
PHP 8.0.25
### Operating System
_No response_