Jarvis Millan Jarvis Millan - 1 month ago 6
MySQL Question

date(y:m:d h:i:s) wont add a time

i need to insert a date that has a date and time. my column is a Datetime.

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


here's my query:

$query = "INSERT INTO user_images (image_name, user_id, date_added) VALUES ('$image_name','$user_id', '$date');";


but then in my table, it didn't add a time.


Answer

Try NOW(), that will use the system time.

$query = "INSERT INTO user_images (image_name, user_id, date_added) VALUES ('$image_name','$user_id', NOW());";
Comments