from_unixtime(create_time)
可以使用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)
- from_unixtime 有两个参数
- 第一个参数可以是数据库字段,也可以是unix时间戳。
- 第二个参数用于定义格式。可缺省。具体格式百度百科。
作者:developerAbble
链接:https://www.jianshu.com/p/82286a226126
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
