2015-01-29 5 views
1

character varying 열의 rfc3339 문자열을 timestamp with timezone으로 올바르게 변환 할 수 있습니까? 시간대가있는 시간 소인으로 rfc3339 문자열 변환

Input: "2015-01-28T17:41:52Z" 
Expected output: "2015-01-28 17:41:52+00" 
Current output: "2015-01-28 17:41:52+01" 

제가

다음
/* begin dummy data */ 
WITH messages as (
    select 123 as id, '2015-01-28T17:41:52Z'::text as received 
) 
/* end dummy data */ 
SELECT id, received, (to_timestamp(received, 'YYYY-MM-DDThh24:MI:SS')) as d 
FROM messages 

TZ 또는 tz 입력 데이터 불가능하며 OFis available in 9.4하지만 not in 9.3 추가하는 시도.

+0

rfc3339는 iso8601의 프로필 일뿐입니다. PostregreSQL은 유효한 iso8601 입력을'date' /'timestamp' /'timestamp with time zone'으로 받아들입니다. (''2015-01-28T17 : 41 : 52Z ':: timestamptz'를 캐스팅 해보십시오.) – pozs

+0

완벽하고 고마워요. 네가 괜찮 으면 대답으로 받아 들일거야. –

답변

2

RFC3339date/timestamp/timestamp with time zone로서 ISO 8601

PostregreSQL accepts any valid ISO 8601 input 단지 프로파일이다. 같은 주조하십시오 :

SELECT '2015-01-28T17:41:52Z'::timestamptz 

: 그러나, (클라이언트에서) 당신의 출력은 항상 current time zone에있을 것입니다.