[php-src] Issue #11901: DateTimeImmutable::createFromFormat() does not support documented 'X' year format argument
| From: | ajgale | Date: | Mon, 07 Aug 2023 17:22:53 +0000 |
| Subject: | [php-src] Issue #11901: DateTimeImmutable::createFromFormat() does not support documented 'X' year format argument | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245118@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11901
Author: ajgale
### Description
According to the [docs](https://www.php.net/manual/en/datetimeimmutable.createfromformat),
'X' or 'x' are recognized in a format parameter string as
> A full numeric representation of a year, up to 19 digits, optionally prefixed by + or -
The following code:
```php
<?php
$result = \DateTimeImmutable::createFromFormat('X-m-d', '20000-01-01');
\var_dump($result);
```
Resulted in this output:
```
bool(false)
```
But I expected this output instead:
```
object(DateTimeImmutable)#1 (3) {
["date"]=>
string(26) "20000-01-01 11:02:40.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(14) "America/Denver"
}
```
### PHP Version
PHP 8.1.2
### Operating System
_No response_