Page 1 of 1

Putting Time and Date Into Mysql

Posted: Mon Oct 28, 2002 6:42 pm
by craka
ok, i cant figure out how to put the time and date into MySQL Using the DATETIME function in MySQL.

$log_names = "insert into sn values ('$name', 'tov')";
$query = mysql_query($log_names);

tov in my data base is where the DATETIME goes. But when it logs the time and date all it logs is 0000-00-00 00:00:00

ANyone know what i should do... Let me remind you that me = noob at PHP and MySQL... lol... i cant be great at it at only 16 and trying to learn on my own.. oh well.. later.

Posted: Mon Oct 28, 2002 6:53 pm
by volka
you're trying to assing the string tov to a field. tov is not a date, is it? ;)
try something like

Code: Select all

$query = "insert into sn (just_a_field_name, a_datetime_field) values ('a string', '2002-10-28')";
\\ or
$query = "insert into sn (just_a_field_name, a_datetime_field) values ('a string', Now())";
http://www.mysql.com/documentation/mysq ... tml#INSERT
http://www.mysql.com/doc/en/TIME.html
http://www.mysql.com/doc/en/DATETIME.html
http://www.mysql.com/doc/en/Date_and_time_types.html
http://www.mysql.com/doc/en/Date_and_ti ... tions.html