Reputation: 414
I am trying to INSERT time which is in format "Tue, 14 Jan 2014 19:56:09 +0530"
using query
INSERT INTO monitor (Date, Name ) VALUES ('$Date','$Name') ";
mysql_query($query) or die ("query failed");
This query execute without any error but when I look into values inserted it was found that value of time in different other than what is in $Date
, value inserted is "0000-00-00 00:00:00"
other than "Tue, 14 Jan 2014 19:56:09 +0530"
. Is any their anything I am doing wrong.
Upvotes: 0
Views: 63
Reputation: 34055
STR_TO_DATE()
inline with your INSERT
. For example, SELECT STR_TO_DATE('01,5,2013','%d,%m,%Y');
... Use the specifiers in this tablemysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which.Upvotes: 5