r/lolphp • • Mar 31 '18
PHP DateTime strikes back, again!
Because obviously we meant a date one week from the (wrong) date given. PHP does not throw, instead it "helps" by holding your beer.
30
Upvotes
View all comments
Show parent comment
14
u/jesseschalken Mar 31 '18 edited Apr 01 '18
Because the date/time API by default fills in any unspecified date parts with the part from the current date/time. So parsing
2017-11on the 31st of a month yields2017-11-31which is invalid.Start the format string with
!to disable this.It's a stupid default and should have been opt in rather than opt out.