Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Changes have made to parsing date time strings in PHP 8 without changelog entries about it

It seems that changes have been made how date time strings are parsed when creating DateTime objects.

Following code gives errors in PHP5 and PHP7, but for PHP8.2 it interprets the three digits after the year as number of days, resulting in the first of february:

var_dump(new DateTime('2023-032'));

Even worse: when given something like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

var_dump(new DateTime('2023-005-03'));

it is interpreted as fifth of january with a timezone of "-03:00" whereas in previous PHP versions errors are thrown.

Where have those changes been made and why aren’t they documented (as in changelogs)?

>Solution :

I suppose that would fall under https://www.php.net/ChangeLog-8.php#8.1.7,

Fixed bug #51987 (Datetime fails to parse an ISO 8601 ordinal date (extended format)).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading