[SQL ] postgresql的epoch问题

楼主: flowwinds (..)   2015-10-03 10:40:49
数据库名称: 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的
值应该如何做?
谢谢~

Links booklink

Contact Us: admin [ a t ] ucptt.com