0
why php inserts 01-01-1970 in mysql?
I m taking date in the format of 12/09/2016 and then by replacing all / with - it will convert to 12-09-2016 bt I dnt know in some cases it will be going as 01-01-1970
2 Respuestas
+ 1
January 1, 1970 is the so called Unix epoch. It's the date where they started counting the Unix time. If you get this date as a return value, it usually means that the conversion of your date to the Unix timestamp returned a (near-) zero result. So the date conversion doesn't succeed. Most likely because it receives a wrong input.
In other words, your strtotime($date1) returns 0, meaning that $date1 is passed in an unsupported format for the strtotime function.
to resolve this problem follow the Code
Replace / with -:
$date1 = strtr($_REQUEST['date'], '/', '-');
echo date('Y-m-d', strtotime($date1));
0
can I add day interval to this converted date?