Re: timezone difference in timestamp? - Mailing list pgsql-general

From Tom Lane
Subject Re: timezone difference in timestamp?
Date
Msg-id 28638.1162840095@sss.pgh.pa.us
Whole thread Raw
In response to timezone difference in timestamp?  (meltedown <asdf@fake.com>)
Responses Re: timezone difference in timestamp?
List pgsql-general
meltedown <asdf@fake.com> writes:
> Short version: I'm trying to turn a unix timestamp into a psql
> timestamp, but there is a 5 hour difference. Is this because of
> timezones ? Can I just subtract 5 hours to get the right value ?

> "select timestamp '1970-01-01' + interval '$startofday seconds' as
> timestamp"

If it really is a Unix timestamp --- ie, referenced to midnight GMT
1970-01-01 --- then you need to start with midnight GMT not midnight
local time as the basis.  So,

select timestamp with time zone '1970-01-01 00:00 GMT' + interval ...

or better yet

select timestamp with time zone 'epoch' + interval ...

            regards, tom lane

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: timezone difference in timestamp?
Next
From: "Andrus"
Date:
Subject: How to force strong passwords