码迷,mamicode.com
首页 > 数据库 > 详细

postgresql获取Unix时间戳

时间:2016-11-15 11:28:59      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:postgresql unixtimestamp

-- 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时间戳

标签:postgresql unixtimestamp

原文地址:http://heyiyi.blog.51cto.com/205455/1872904

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!