When my MySQl dates are null, PHP returns them as '-0001-11-30 00:00:00'.
I know this is because I am using Europe timezone but how can I handle this?
I keep getting:
InvalidArgumentException in Carbon.php line 425:
Unexpected data found.
in Carbon.php line 425
at Carbon::createFromFormat('Y-m-d H:i:s', '-0001-11-30 00:00:00') in Model.php line 2915
How can I fix this?
Mick
NB: This is different from : How do you explain the result for a new \DateTime('0000-00-00 00:00:00')?
It is different because I am asking what I am supposed to do about it.
Basing on this great answer: https://stackoverflow.com/a/19075291/4499267 at point 8) it says that
MySQL stores "0000-00-00 00:00:00" if you set a datetime column as NULL, unless you specifically set the column to allow null when you create it.
So that might be the solution, to create the table with a nullable datetime column
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With