生成随机时间
-- 带时分秒
select FROM_UNIXTIME(UNIX_TIMESTAMP('20100101000000')+ROUND(RAND()*(UNIX_TIMESTAMP()-UNIX_TIMESTAMP('20100101000000'))));
-- 确定日期,随机时间
SELECT concat('2018-03-03 ', floor(10+rand()*10),':',floor(10+rand()*49),':',floor(10+rand()*49));
获取时间
-- 获取时间、时间戳(秒、毫秒)
SELECT TIME_TO_SEC(NOW()), NOW(), CURRENT_TIMESTAMP(), REPLACE(UNIX_TIMESTAMP(NOW(3)),'.','') AS 毫秒数, REPLACE(UNIX_TIMESTAMP(NOW(0)),'.','') AS 秒数, REPLACE(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)),'.',''), CURRENT_TIMESTAMP(3), UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3));
-- 时间戳转日期
SELECT FROM_UNIXTIME(1515980716, '%Y-%m-%d %H:%i:%S');