Take the 2-minute tour ×

I'm trying to update my datetime field in a table with the following PHP datetime:

$datetime = date('d/m/Y H:i:s');

Unfortunately the datetime field in the table is NULL

How can I update a datetime field with $datetime ?


share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

right format is Y-m-d H:i:s anyway in your SQL query you can use NOW()


share|improve this answer
You can also instead of now() use current_timestamp in mysql query. –  pregmatch Nov 30 '12 at 20:58
add comment
$datetime = date('Y-m-d H:i:s');

will work. DATETIME columns must be in a Y-m-d H:i:s format, not d-m-Y H:i:s.

From the manual:

The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format.

share|improve this answer
add comment

The correct format is Y-m-d H:i:s.

share|improve this answer
add comment

Your Answer


