• 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';