问题
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