I have a DATETIME column(Default is NULL) in MySQL and trying to insert Empty or NULL value. But I am getting "Incorrect datetime value: '' " error message. If I insert 'NULL' then I am getting "Incorrect datetime value: 'NULL'" error message. How can I insert a blank or NULL value in this column? Thank you for any suggestions.
Here is the code.
if (empty($_POST["date_field"]))
{
$Date1 = 'NULL';
}
else
{
$Date1 = strtotime($_POST["date_field"]);
$Date1 = date("Y-m-d H:i:s", $Date1);
}
INSERT INTO Table1(date_field) VALUES('" .$Date1. "');