PDA

View Full Version : [PHP] Unix Timestamp



ducktape
May 16th, 2004, 12:58
I forgot how to insert a unix timestamp into a db. I know how to insert it but i forgot how to generate it. i used something like




$stamp = date (now());



but it doesnt work right. I know i am not doing it right. I cant find the snippet from one of my old sites i used and forgot how. But I need to insert the timestamp from the unix epoch.

bloodyveins
May 16th, 2004, 18:18
time() -> create unix timestamp (integer) from current time
mktime(args[i],..,args[n]) -> create unix timestamp from arguments
date(format, timestamp) -> create date in certain format from timestamp

mattsoft
May 16th, 2004, 18:50
if you'd like to do it in mysql code, either NOW() for a date field or UNIX_TIMESTAMP(NOW()) for an integer. hope that helps :-)