首页 > 代码库 > postgresql获取Unix时间戳

postgresql获取Unix时间戳

-- timestamp to unix timestamp

select now(), EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE ‘now()‘)::int as ext, extract(epoch FROM now())::int, CURRENT_TIMESTAMP,date_part(‘epoch‘,CURRENT_TIMESTAMP)::int

-- unix timestamp to timestamp

SELECT TIMESTAMP WITH TIME ZONE ‘epoch‘ + 982384720.12 * INTERVAL ‘1 second‘;

--SELECT TIMESTAMP WITH TIME ZONE ‘epoch‘ + extract(epoch FROM now())* INTERVAL ‘1 second‘;


本文出自 “yiyi” 博客,请务必保留此出处http://heyiyi.blog.51cto.com/205455/1872904

postgresql获取Unix时间戳