如何将 DateTime 转换为 MySQL 中的数字?
如何从 MySQL 中的 DateTime 实例获取自 '1970-01-01 00:00:01'
以来的总秒数?
How can I get the total number of seconds since '1970-01-01 00:00:01'
from a DateTime instance in MySQL?
推荐答案
你正在寻找 UNIX_TIMESTAMP()
.
参见:http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_unix-timestamp
如果使用日期参数调用 UNIX_TIMESTAMP(),它会返回参数的值作为自 '1970-01-01 00:00:00' UTC 以来的秒数.
If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC.
相关文章