简体   繁体   中英

Php and Mysql date in seconds are different for current time stamp

using TO_SECONDS(DATE_FORMAT( NOW( ) , '%Y-%m-%d %h:%i:%s' ) ) I am getting current time in seconds but at the same time when i try to find time in seconds by server using strtotime(strftime("%F %T %p")) it's different. eg: mysql gives 63657226218 seconds whereas php unix time is 1489986896.

Thanx in advance

TO_SECONDS Given a date or datetime expr, returns a the number of seconds since the year 0 . Not 1970!

You want to use UNIX_TIMESTAMP:

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