补充:日期和时间戳互转
1. 日期转时间戳
-- 转十位
select UNIX_TIMESTAMP('2018-12-25 12:25:00');
结果:1545711900
-- 转十三位
SELECT REPLACE(unix_timestamp(current_timestamp(3)),'.','');
结果:1545711900021
2. 时间戳转日期 FROM_UNIXTIME(unix_timestamp)
select FROM_UNIXTIME(1545711900);
结果:2018-12-25 12:25:00
select FROM_UNIXTIME(1545711900,'%Y-%m-%d %T');(自定义返回日期格式)
-- 结果:2018-12-25 12:25:00
3. 函数
DATE_FORMAT(date,format)函数:用于以不同的格式显示日期/时间数据
date 参数是合法的日期;
format 规定日期/时间的输出格式;



示例:
select DATE_FORMAT(NOW(), '%Y-%m-%d %T');
结果:2018-12-25 12:25:00