now() and time zone

Started by Jean-Christophe Rouxover 19 years ago4 messagesgeneral
Jump to latest
#1Jean-Christophe Roux
jcxxr@yahoo.com

Hello,
I am a bit sorry to come back on that topic but I just cannot get it right. How comes that
select now() at time zone 'EST'
returns
"2006-10-04 15:59:26.713623"
when it is actually 16:59 on the east coast? Can it be that the server where the PostgreSQL database is located is not properly configured?
Many thanks
Jean

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Jean-Christophe Roux (#1)
Re: now() and time zone

On Wed, Oct 04, 2006 at 02:01:18PM -0700, Jean-Christophe Roux wrote:

Hello,
I am a bit sorry to come back on that topic but I just cannot get it right. How comes that
select now() at time zone 'EST'
returns
"2006-10-04 15:59:26.713623"
when it is actually 16:59 on the east coast? Can it be that the server where the PostgreSQL database is located is not properly configured?

Maybe there's summar time/daylight savings time? I'm unsure if "EST" is
supposed to reflect that.

You can say things like:

select now() at time zone 'America/California';

Perhaps that gets you something more reasonable?

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

From each according to his ability. To each according to his ability to litigate.

#3Jean-Christophe Roux
jcxxr@yahoo.com
In reply to: Martijn van Oosterhout (#2)
Re: now() and time zone

Yes you are right, that's what I have just realized; I should be using EDT instead of EST. Sorry for the bother
JCR

----- Original Message ----
From: Martijn van Oosterhout <kleptog@svana.org>
To: Jean-Christophe Roux <jcxxr@yahoo.com>
Cc: pgsql-general@postgresql.org
Sent: Wednesday, October 4, 2006 5:06:42 PM
Subject: Re: [GENERAL] now() and time zone

On Wed, Oct 04, 2006 at 02:01:18PM -0700, Jean-Christophe Roux wrote:

Hello,
I am a bit sorry to come back on that topic but I just cannot get it right. How comes that
select now() at time zone 'EST'
returns
"2006-10-04 15:59:26.713623"
when it is actually 16:59 on the east coast? Can it be that the server where the PostgreSQL database is located is not properly configured?

Maybe there's summar time/daylight savings time? I'm unsure if "EST" is
supposed to reflect that.

You can say things like:

select now() at time zone 'America/California';

Perhaps that gets you something more reasonable?

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

From each according to his ability. To each according to his ability to litigate.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jean-Christophe Roux (#1)
Re: now() and time zone

Jean-Christophe Roux <jcxxr@yahoo.com> writes:

I am a bit sorry to come back on that topic but I just cannot get it right. How comes that
select now() at time zone 'EST'
returns
"2006-10-04 15:59:26.713623"
when it is actually 16:59 on the east coast?

USA east coast is currently on EDT ... not EST.

In PG 8.1 and later you can say AT TIME ZONE 'EST5EDT' or
AT TIME ZONE 'America/New_York' to get the behavior I think you are
after.

regards, tom lane