php timestamp function needed [duplicate]
开发者_高级运维Possible Duplicate:
Formatting a timestamp
I require a php function that returns the date in the format in the same format as mySQL function CURRENT_TIMESTAMP (i.e like this--> 2011-08-10 17:17:23).
Wondering if there's anything available
echo date("Y-m-d H:i:s");
will do the job.
You can use the date() function for this.
// example result 2010-08-12 22:30:45
$mysqlTime = date ("Y-m-d H:i:s");
Also if you want to get a MySQL date as a timestamp for use in php functions you can use MySQL's UNIX_TIMESTAMP function
精彩评论