저는 TIMESTAMP WITHOUT TIME ZONE
유형의 열을 가지고 있으며 그 기본값을 현재 시간 (UTC)으로하고 싶습니다. 컬럼의 현재 타임 스탬프 사용PostgreSQL의 기본값으로 UTC의 현재 시간을 사용합니다
postgres=# select now() at time zone 'utc';
timezone
----------------------------
2013-05-17 12:52:51.337466
(1 row)
으로 : UTC의 현재 시간을 얻는 것은 쉬운
postgres=# create temporary table test(id int, ts timestamp without time zone default current_timestamp);
CREATE TABLE
postgres=# insert into test values (1) returning ts;
ts
----------------------------
2013-05-17 14:54:33.072725
(1 row)
을하지만 로컬 시간을 사용합니다. 구문 오류 UTC 결과에 그것을 강제로 시도 :
postgres=# create temporary table test(id int, ts timestamp without time zone default now() at time zone 'utc');
ERROR: syntax error at or near "at"
LINE 1: ...int, ts timestamp without time zone default now() at time zo...
는) 정말 빛나는 – misaxi
시간이 다시 시간을가는 경우에도 작동 - 지금()을 알고있는 타임 스탬프를 반환 UTC에서 오프셋. –