数据库时间戳与日期互转

mysql

-- 日期字符串转时间戳
select UNIX_TIMESTAMP('2019-09-01 00:00:00');
-- 时间戳转日期
select FROM_UNIXTIME(1567267200,'%Y-%m-%d %H:%i:%s');

phoenix

DATA_TIME为BIGINT类型的毫秒时间戳

-- 日期字符串转时间戳
select to_char(to_number(to_date('2021-03-17 23:50:47','yyyy-MM-dd HH:mm:ss','GMT+8')),'#');
-- 时间戳转日期
select to_date(to_char(DATA_TIME/1000,'#'),'s','GMT-8');
posted @ 2021-08-26 14:12  梦玄庭  阅读(881)  评论(0编辑  收藏  举报