作者flowwinds (..)
看板Database
标题[SQL ] postgresql的epoch问题
时间Sat Oct 3 10:40:49 2015
资料库名称: Postgresql
资料库版本: 9.3
内容/问题描述:
我想得到已存在timestamp栏位的整数值, 栏位格式是:timestamp without time zone
看到有语法可以这样做 SELECT EXTRACT(epoch from 栏位名), 单位:second
但对於epoch, 官方文件中写到:
"For timestamp with time zone values, the number of seconds since 1970-01-01
00:00:00 UTC (can be negative); for date and timestamp values, the number of
seconds since 1970-01-01 00:00:00 local time;..."
後面那句应该是指timestamp without time zone类型, 所以对此类型而言, 得到的epoch
值有考量db的时区进去
我原本存进栏位的值都是 UTC, 但用那语法取出来的是含db时区的值, 想得到原本UTC的
值应该如何做?
谢谢~
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.162.18.188
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Database/M.1443840052.A.9E1.html
※ 编辑: flowwinds (1.162.18.188), 10/03/2015 10:45:09