time format from MySQL database column is unrecognisable

我只是一个虾纸丫 提交于 2020-01-06 08:11:11

问题


I have a Mysql database table and it has a column "Created time" which has values like 1538899092000 , 1543476095000 and so on. What is this ? and how to convert this into our regular format ? Thanks in advance.


回答1:


It looks like a Unix timestamp multiplied by 1,000 (i.e. in milliseconds rather than seconds). These kinds of timestamps are used in JavaScript.

Use FROM_UNIXTIME(created_time/1000) to convert it to a DATETIME.

mysql> select from_unixtime(1543476095000/1000);
+-----------------------------------+
| from_unixtime(1543476095000/1000) |
+-----------------------------------+
| 2018-11-29 01:21:35               |
+-----------------------------------+

And use 1000 * UNIX_TIMESTAMP(datetime value) to convert a DATETIME to this format.



来源:https://stackoverflow.com/questions/54676441/time-format-from-mysql-database-column-is-unrecognisable

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