Skip to content

Conversation

@homersimpsons
Copy link
Contributor

@homersimpsons homersimpsons commented Oct 13, 2025

Updated descriptions for Y format to clearly shows that 2 digit years may lead to unexpected results.

I removed 0055 as the same example is provided as 0025.

To me this is not clear enough, I wanted to parse a Y-m-d or y-m-d:

$date = '25-10-13';
$parsed = DateTime::createFromFormat('Y-m-d', $date) ?: DateTime::createFromFormat('y-m-d', $date); // 13-10-0025
$parsed = DateTime::createFromFormat('y-m-d', $date) ?: DateTime::createFromFormat('Y-m-d', $date); // 13-10-2025

Updated descriptions for `Y` format to clearly shows that 2 digit years may lead to unexpected results.
@TimWolla TimWolla changed the title 📝 Document Y format footgun Document Y format footgun Oct 15, 2025
@kamil-tekiela kamil-tekiela merged commit dcf89d1 into php:master Oct 15, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants