pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan Brinkman <JB@BlackSkyTech.com>
To: 'Tom Lane' <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: TO_CHAR(timestamptz,datetimeformat) wrong after DST change
Date: Fri, 18 Mar 2011 12:01:25 -0400
Message-ID: <005601cbe585$bc7d4b10$3577e130$@com> (raw)
In-Reply-To: <15708.1300462903@sss.pgh.pa.us>
References: <004c01cbe57c$7d920ca0$78b625e0$@com>
	<15708.1300462903@sss.pgh.pa.us>

When in a command prompt I log into psql with merely "psql" and get
postgres=#, and run SELECT now(); I get the correct time.
When I log into my application's database with psql beta_cms_gate and get
beta_cms_gate=# prompt, and run SELECT now(); I get incorrect time (still
-05 timezone, and 1 hour too early).

When I use psql and show time zone; I get "America/New_York".
When I use psql beta_cms_gate and show time zone; I get "EST".

I guess EST is not DST-friendly? My postgresql.conf is set to "America/New
York".

Within my DB I ran set time zone 'America/New_York'; and retried the select
now(), and now it is correct.


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Sent: Friday, March 18, 2011 11:42 AM
To: JB@BlackSkyTech.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] TO_CHAR(timestamptz,datetimeformat) wrong after DST
change

"Jonathan Brinkman" <JB@BlackSkyTech.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




view thread (10+ messages)  latest in thread

Message-ID: <005601cbe585$bc7d4b10$3577e130$@com>
Permalink:  ../005601cbe585$bc7d4b10$3577e130$@com/
Also on:    postgresql.org/message-id/005601cbe585$bc7d4b10$3577e130$@com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: JB@BlackSkyTech.com, tgl@sss.pgh.pa.us
  Subject: Re: TO_CHAR(timestamptz,datetimeformat) wrong after DST change
  In-Reply-To: <005601cbe585$bc7d4b10$3577e130$@com>
  References: <004c01cbe57c$7d920ca0$78b625e0$@com> <15708.1300462903@sss.pgh.pa.us> <005601cbe585$bc7d4b10$3577e130$@com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox