Convert mysql DATETIME column to epoch seconds

不问归期 提交于 2019-11-28 07:00:30

问题


I have a column mysql datetime that is in DATETIME format.

Is there a way to SELECT this column in epoch seconds? If not, what would be the best way of converting the datetime format to epoch seconds? What type of field would be the best to capture this?


回答1:


Use MySQL's UNIX_TIMESTAMP function




回答2:


You can use :

SELECT UNIX_TIMESTAMP(yourfield) FROM yourtable;

And for UPDATE, the invers function is : FROM_UNIXTIME(...)



来源:https://stackoverflow.com/questions/10839151/convert-mysql-datetime-column-to-epoch-seconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!