I am doing a migration and dates coming as ‘0000-00-00 00:00:00’ and running through strtotime() and returning as false are saving as -2147483648 in the new table’s column, which is an INT datatype. No matter whether I set the default to 0 or NULL, it stills saves as that negative number. I want to avoid having to code exceptions for each date field (and I don’t have the option to change the datatype), so is there some easy way in PHP (using one line) or MySQL to have the default be set on these “empty” dates?
I am doing a migration and dates coming as ‘0000-00-00 00:00:00’ and running through
Share
The time
0000-00-00is outside the range ofstrtotimewhich is bounded by 1901-12-13 through 2038-01-19. It’s returning the lower bound on your broken data. This is common to nearly all UNIXtime_tbased functions.My advice is to replace those dates with
NULLbefore processing. They’re not valid.