View Full Version : MySQL Time Stamp

02-20-2008, 05:35 AM
Hey all, set up a small time stamp. When I insert results manually I click the little calendar and click current date, it inserts something like 2008-02-19 23:30:15

How would I be able to insert the same through php?

02-20-2008, 07:49 AM
$date=gmdate("Y-m-d H:i:s");
mysql_query("insert into table_name(date) values('$date')") or die(mysql_error()); ??

Deacon Frost
02-20-2008, 08:14 AM
Doesn't this workish?

function formatDate($val)
list($date, $time) = explode(" ", $val);
list($year, $month, $day) = explode("-", $date);
list($hour, $minute, $second) = explode (":", $time);
return date("l, m.j.y @ H:ia", mktime($hour, $minute, $second, $month, $day, $year));


`date` datetime NOT NULL default '0000-00-00 00:00:00'

or some variation of that. then you just select it from the database in an include and add it to it?