1.日期转时间戳
-- 转十位
select UNIX_TIMESTAMP('2018-12-25 12:25:00');
结果:1545711900
-- 转十三位
SELECT REPLACE(unix_timestamp(current_timestamp(3)),'.','');
结果:1545711900021
2.时间戳转日期:FROM_UNIXTIME(unix_timestamp) --unix_timestamp为时间戳
select FROM_UNIXTIME(1545711900);
结果:2018-12-25 12:25:00
3.时间戳转日期,自定义返回日期格式:FROM_UNIXTIME(unix_timestamp,format) -- format请参考后面的截图
select FROM_UNIXTIME(1545711900,'%Y-%m-%d %T');
-- 结果:2018-12-25 12:25:00
09-02
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-18
1434
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交