Hello i want to send to a MySQL data base a date and time in a format compatible with the mysql DateTime format, wich is: 0000-00-00 00:00:00 ...
Im using this code who brings the date and time from a PHP command:
$insert = "INSERT INTO sms (ref, texto, fecha)
VALUES ('".$_POST['usuario']."', '".$_POST['sms']."', '".date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000))."')";
$add_member = mysql_query($insert);
I really want to do this but with a MySQL command, i mean, using the Date and Time from the mysql server. Thanks
解决方案
Use NOW() when inserting the record INSERT INTO table (date) VALUES (NOW())
For your code:
$insert = "INSERT INTO sms (ref, texto, fecha)
VALUES ('".$_POST['usuario']."', '".$_POST['sms']."', NOW() )";
$add_member = mysql_query($insert);