Re: TO_CHAR(timestamptz,datetimeformat) wrong after DST change

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: JB(at)BlackSkyTech(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: TO_CHAR(timestamptz,datetimeformat) wrong after DST change
Date: 2011-03-18 15:41:43
Message-ID: 15708.1300462903@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Jonathan Brinkman" <JB(at)BlackSkyTech(dot)com> writes:
> My TO_CHAR function is now an hour off thanks to Daylight Savings Time.
> The dates are correct (I'm in EST: TZ=-04) but my function now returns TIME
> an hour early.
> (prior to DST we were TZ=-05).

> TIMESTAMPTZ data (v_dt): 2011-03-17 18:21:50-04
> FUNCTION SNIPPET: to_char(v_dt, 'mm/dd/yyyy hh:mi AM')
> FUNCTION RETURNS: 03/18/2011 09:21 AM
> FUNCTION SHOULD RETURN: 03/18/2011 10:21 AM

> postgres=# show time zone;
> TimeZone
> ------------------
> America/New_York
> (1 row)

Works for me:

regression=# set timezone = 'America/New_York';
SET
regression=# select now();
now
-------------------------------
2011-03-18 11:39:45.124162-04
(1 row)

regression=# select to_char(now(), 'mm/dd/yyyy hh:mi AM');
to_char
---------------------
03/18/2011 11:39 AM
(1 row)

Are you sure your application is running with the timezone setting you
think it is?

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jonathan Brinkman 2011-03-18 16:01:25 Re: TO_CHAR(timestamptz,datetimeformat) wrong after DST change
Previous Message Jonathan Brinkman 2011-03-18 14:55:03 TO_CHAR(timestamptz,datetimeformat) wrong after DST change