Im trying to get the current time in PHP using
$sTime = date("Y-m-d H:i:s");
and store it in a mysql table in a datetime column like:
$sTQuery = "INSERT INTO Actions(UserID, StartDuration) VALUES ('$UserID' , '$sTime')";
The date echos as expected but in the table it just shows 0000-00-00 00:00:0.
I have tried using now() in the query but still get 0000-00-00 00:00:0 in the table.
Edit: In the mysql table the column the date and time is to be stored in is a datetime
now(), make sure to use that without quotes. Although depending on the column type, you may need a different function likecurrent_timestamp().0000-00-00 00:00:0missing?SELECTquery you are testing with, so we can try to reproduce the problem. Also provide the result toSELECT NOW().