#title TimeZone time zone name {{{ select * from pg_timezone_names where name like '%Seoul%' }}} {{{ --postgresql.conf의 timezone이 utc로 세팅되어 있고, 실제 timezone은 Asia/Seoul일 때 drop table utc_test; create table utc_test(dt timestamptz); --입력방법 insert into utc_test(dt) values ('2016-03-11 06:11:12.431928'::timestamp at time zone 'Asia/Seoul'), ('2016-03-12 06:11:12.431928+09'::timestamptz), ('2016-03-12 06:11:12.431928'::timestamp + interval '-09:00'); --조회방법 select dt at time zone 'Asia/Seoul' , dt from utc_test where 1=1 and dt >= ('2016-03-11'::timestamp at time zone 'Asia/Seoul') and dt < ('2016-03-12'::timestamp at time zone 'Asia/Seoul'); }}} {{{ --postgresql.conf의 timezone이 utc로 세팅되어 있을 때에 --'2016-03-11 16:11:12.431928'는 Asia/Seoul time이라면 select '2016-03-11 16:11:12.431928'::timestamptz --> 문자열 자체를 utc로 인식한다. , '2016-03-11 16:11:12.431928'::timestamp at time zone 'Asia/Seoul' --> utc 시간으로 변환한다. , '2016-03-11 16:11:12.431928' at time zone 'Asia/Seoul' --> 문자열이 utc 시간으로 가정하고 Asia/Seoul 시간으로 변환한다. --'2016-03-11 16:11:12.431928' --> Asia/Seoul time이라면.. select dt --> 9시간 빼고 저장한 것: utc , dt at time zone 'Asia/Seoul' from (select '2016-03-11 16:11:12.431928'::timestamp at time zone 'Asia/Seoul' dt) t }}}