开发者

php timestamp function needed [duplicate]

开发者 https://www.devze.com 2023-03-27 10:22 出处:网络
This question already has an answer here: Closed 11 years ago. 开发者_高级运维Possible Duplicate:
This question already has an answer here: Closed 11 years ago.

开发者_高级运维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

0

精彩评论

暂无评论...
验证码 换一张
取 消