3 ms·
PHP: Bug #45647
- CarolineW 11y agoThis seems perfectly reasonable to me. 00-00-00 is a two digit year, hence 2000-00-00 2000-00 is the month before 2000-01, hence 1999-12 Then we have 1999-12-00 That's the day before 1999-12-01, hence 1999-11-30 And that's what it gives. If you're going to ask for month 0 and day 0, expect "interesting" results.
- smt88 11y agoJust because there is a way to explain a certain behavior doesn't mean it's the right way for the code to behave. This definitely violates the law of least surprise. Furthermore, no one who writes "00-00-00" means "2000-00-00" because that's not a real date. We can say with certainty that no one actually wants "00-00-00 00:00:00" to mean a date in 1999! That string -- a date with all zeros -- is common in MySQL when an empty value is passed to a not-null date field, so we can be even more certain that interpreting that weird date as "some time in 1999" is going to introduce lots of bugs. It would make much, much more sense for PHP to just fail to parse the date.