使用 mysql 内置的函数 from_unixtime 进行转换
mysql> select id, time from log order by id desc limit 5;
+-----+------------+
| id | time |
+-----+------------+
| 897 | 1567411753 |
| 896 | 1567411707 |
| 895 | 1567402661 |
| 894 | 1567402402 |
| 893 | 1567402315 |
+-----+------------+
5 rows in set (0.01 sec)
mysql> select id, from_unixtime(time) from log order by id desc limit 5;
+-----+---------------------+
| id | from_unixtime(time) |
+-----+---------------------+
| 897 | 2019-09-02 16:09:13 |
| 896 | 2019-09-02 16:08:27 |
| 895 | 2019-09-02 13:37:41 |
| 894 | 2019-09-02 13:33:22 |
| 893 | 2019-09-02 13:31:55 |
+-----+---------------------+
5 rows in set (0.00 sec)
微信关注我哦 👍
我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式