from_unixtime(create_time)

2018-02-02  本文已影响26人  developerAbble

查看数据库数据,如果时间比如create_time是unix时间戳,必然很不方便。

可以使用from_unixtime函数进行格式转换。效果如下:

MariaDB [education]> select id, from_unixtime(create_time)
 from cmf_student_calendar where id = 138;
+-----+----------------------------+
| id  | from_unixtime(create_time) |
+-----+----------------------------+
| 138 | 2018-02-02 20:31:18        |
+-----+----------------------------+
1 row in set (0.00 sec)


MariaDB [education]>  select id, from_unixtime(1517574678, '%Y-%m-%d')
 from cmf_student_calendar where id = 138; 
| id  | from_unixtime(1517574678, '%Y-%m-%d') |
+-----+---------------------------------------+
| 138 | 2018-02-02                            |
+-----+---------------------------------------+
1 row in set (0.00 sec)
上一篇下一篇

猜你喜欢

热点阅读