r/lolphp • u/pilif • Jun 26 '23
Making sure a string is conformant to a date format still requires preg_match I guess.
https://3v4l.org/otkfPZ
15
Upvotes
r/lolphp • u/pilif • Jun 26 '23
7
u/pilif Jun 26 '23
While the format string
Ymeans "at least 4 digits", when using it for the strictest way of parsing a date,DateTimeis still trying to be helpful and interpretsYas "up to 4 digits".Which also is going to be a problem once we reach year 10k, though I surely won't be around any more to deal with this crap by then.
3
u/pilif Jun 26 '23
Also: https://3v4l.org/OoYWg
3
u/midir Jun 26 '23
Where the fuck did it pull the time from?
2
u/Takeoded Dec 30 '23
Technically PHP is correct here: If you really want to refer to 1st january year 22 using the date format Y-m-d,
22-01-01is correct..1
u/shitcanz Jun 28 '23
Need to work with dates? You should not reach for PHP, as its a nightmare to juggle all the weird edge cases the core datetime module suffers from. Been burned many times before.
-4
u/colshrapnel Jun 26 '23
Rather, it needs RTFM. https://3v4l.org/BFPaq
0
u/[deleted] Jun 27 '23
[deleted] — view deleted comment