简体   繁体   English

以秒为单位的Php和Mysql日期对于当前时间戳是不同的

[英]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. 使用TO_SECONDS(DATE_FORMAT( NOW( ) , '%Y-%m-%d %h:%i:%s' ) )我在几秒钟内获得当前时间,但同时我尝试在几秒钟内找到时间服务器使用strtotime(strftime("%F %T %p"))它是不同的。 eg: mysql gives 63657226218 seconds whereas php unix time is 1489986896. 例如:mysql给出63657226218秒,而php unix时间为1489986896。

Thanx in advance Thanx提前

TO_SECONDS Given a date or datetime expr, returns a the number of seconds since the year 0 . TO_SECONDS给定日期或日期时间expr,返回自0年以来的秒数。 Not 1970! 不是1970年!

You want to use UNIX_TIMESTAMP: 您想使用UNIX_TIMESTAMP:

select UNIX_TIMESTAMP(NOW());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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