Re: Getting the name of the timezone, adjusted for daylight saving

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Morgan Lloyd <markMLl(dot)pgsql-general(at)telemetry(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting the name of the timezone, adjusted for daylight saving
Date: 2011-01-26 19:55:34
Message-ID: 24078.1296071734@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mark Morgan Lloyd <markMLl(dot)pgsql-general(at)telemetry(dot)co(dot)uk> writes:
> Thanks Tom. Timestamps are going into the database which are implicitly
> UTC, and I was looking for a way to convert them when displayed to the
> local timezone (the client gets this from a configuration file and puts
> it in the query) and also to present the timezone name.

Consider setting timezone to what the client asks for.

> So I think that what you're saying is that the result from to_char()
> will always be UTC, possibly corrected for daylight saving (i.e. GMT or
> BST respectively).

No, the result is computed on the assumption that we're in the zone
specified by the timezone setting. This might be hard to wrap your head
around if you only test in GMT or GMT0BST zones --- try something where
the offset is never zero to get a clearer picture of what's going on.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2011-01-26 20:25:46 Re: check on foreign table?
Previous Message Steve Crawford 2011-01-26 19:20:37 Re: Getting the name of the timezone, adjusted for daylight saving