Insert Date into MySQL table
Posted on 2011-05-07
I have a web service that receives certain data. This data includes a "date" field which contains the date in the following format:
"Tue Apr 07 22:52:51 +0000 2009"
I need to insert this date into a MySQL table which contains a TIMESTAMP column.
Currently, I'm trying to do this:
$date = strtotime($strDate); // Here $strDate is the supplied date in the above mentioned format
Query: INSERT INTO <table_name> (`id`, `date_col`) VALUES (NULL, $date);
The problem is that the row is inserted successfully, but the value inserted into the timestamp column is "0000-00-00 00:00:00"
Please let me know where I'm going wrong. Its pretty urgent.