简体   繁体   中英

How to convert the now() to timestamp

嗨,我正在构建自己的php应用程序,我是php初学者,所以当我想获得用户执行特定操作的时间时,我使用NOW()函数来获取它,但是我的问题是如何转换我从mysql NOW()函数获取的时间值

PHP has a function to convert a date string to a timestamp it is called: strtotime() .

http://php.net/manual/de/function.strtotime.php

SELECT TIMESTAMP( NOW() )

This should get you the timestamp ;)

OR, in PHP:

$now = strtotime($dbdata->currentDate);

更好的是,在MySQL中完成所有操作:

SELECT UNIX_TIMESTAMP( NOW() );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM