如何在MySQL中将DateTime转换为数字? [英] How to convert DateTime to a number in MySQL?
本文介绍了如何在MySQL中将DateTime转换为数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从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/zh-CN/date-and-time-functions.html#function_unix-timestamp
如果使用日期参数调用UNIX_TIMESTAMP(),它将返回自1970年1月1日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.
这篇关于如何在MySQL中将DateTime转换为数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文