[php-src] Issue #8278: DateTime::createFromFormat("Y/m") will create bad date
| From: | cmb69 | Date: | Wed, 30 Mar 2022 12:51:25 +0000 |
| Subject: | [php-src] Issue #8278: DateTime::createFromFormat("Y/m") will create bad date | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-240575@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8278
Comment Author: cmb69
From the [docs](https://www.php.net/manual/en/datetime.createfromformat.php):
> If format does not contain the character ! then portions of the generated time which are not
> specified in format will be set to the current system time.
>
> If format contains the character !, then portions of the generated time not provided in format,
> as well as values to the left-hand side of the !, will be set to corresponding values from the Unix
> epoch.
>
> The Unix epoch is 1970-01-01 00:00:00 UTC.
So you can choose which behavior you want to have. The OP is looking for https://3v4l.org/8pQRO. Changing the default would be a serious
and unnecessary BC break.