3 ms·
Just 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 surp
by smt88 11y ago
Just 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.