[php-src] Issue #10479: On some dates, DateTime::createFromFormat incorrect parse date from 'Y-m' format

From: Date: Tue, 31 Jan 2023 17:32:35 +0000
Subject: [php-src] Issue #10479: On some dates, DateTime::createFromFormat incorrect parse date from 'Y-m' format
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243600@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10479
Author: peresmishnyk

### Description

The following code:

```php
<?php
```
// I am running it on 2023-01-31 and it failed but if local time is set to 2023-02-01 all works as
expected
var_dump(DateTime::createFromFormat('Y-m','2022-02'));

Resulted in this output:
```
```
object(DateTime)#6654 (3) {
  ["date"]=>
  string(26) "2022-**03-03** 16:56:07.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(3) "UTC"
}


But I expected this output instead:
```
```
object(DateTime)#6654 (3) {
  ["date"]=>
  string(26) "2022-**02-28** 16:56:07.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(3) "UTC"
}


### PHP Version

PHP 8.1.14

### Operating System

_No response_


Thread (1 message)

  • peresmishnyk
« previous php.bugs (#243600) next »