0
点赞
收藏
分享

微信扫一扫

pg timestamp与unix时间戳之间的转换

眼君 2022-07-13 阅读 133


  • timestamp 类型 转换为 unix 时间戳

select extract (epoch from timestamp '2020-04-09'); -- 1586390400
select extract (epoch from timestamp '2020-04-09 23:59:59'); --1586476799

  • unix时间戳转换为 timestamp 类型

select to_timestamp(45646544)::timestamp without time zone;  --1971-06-13 15:35:44

  • unix 时间戳转换为 timestamp 类型 方法2

SELECT TIMESTAMP WITHOUT TIME ZONE 'epoch' + 1586390400 * INTERVAL '1 second';


举报

相关推荐

0 条评论