[php-src] Issue #10485: IntlDateFormatter::formatObject returns wrong year
| From: | nickbo90 | Date: | Thu, 02 Feb 2023 14:16:51 +0000 |
| Subject: | [php-src] Issue #10485: IntlDateFormatter::formatObject returns wrong year | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243617@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10485
Author: nickbo90
### Description
When using '2022-01-01' as date, IntlDateFormatter returns year 2021 instead of 2022. Same
when using '2022-01-02', but when using '2022-01-03' you will get the correct
year.
The following code:
```
<?php
echo IntlDateFormatter::formatObject(DateTime::createFromFormat('Y-m-d',
'2022-01-01'), "MMMM Y").PHP_EOL;
echo IntlDateFormatter::formatObject(new DateTime('2022-01-01'), "MMMM
Y").PHP_EOL.PHP_EOL;
echo IntlDateFormatter::formatObject(DateTime::createFromFormat('Y-m-d',
'2022-01-03'), "MMMM Y").PHP_EOL;
echo IntlDateFormatter::formatObject(new DateTime('2022-01-03'), "MMMM Y");
```
Resulted in this output:
```
januari 2021
januari 2021
januari 2022
januari 2022
```
But I expected this output instead:
```
januari 2022
januari 2022
januari 2022
januari 2022
```
### PHP Version
PHP 8.2.1
### Operating System
_No response_