Re: selecting current UTC time

From: Frank Bax <fbax(at)sympatico(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: selecting current UTC time
Date: 2008-09-14 12:55:18
Message-ID: 48CD09B6.8010001@sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

davidn(at)xnet(dot)co(dot)nz wrote:
> Hi,
>
> Is it possible to select the current UTC time as type timestamp with time
> zone?
>
> select localtimestamp;
>
> 2008-09-14 21:55:24.367796
>
> select localtimestamp at time zone 'UTC';
>
> 2008-09-15 09:55:42.3478+12
> (not sure if what this result is)
>
> select current_timestamp;
>
> 2008-09-14 21:55:57.844422+12
>
> select current_timestamp at time zone 'UTC';
>
> 2008-09-14 09:56:07.661157
> (is type timestamp without time zone)
>
> I know this seems like a simple problem but I have searched the archives
> and am unable to find a solution.
>
> Any ideas?

default=> select localtimestamp, current_timestamp;
timestamp | now
----------------------------+-------------------------------
2008-09-14 08:54:19.488303 | 2008-09-14 08:54:19.488303-04
(1 row)

default=> set time zone utc;
SET
default=> select localtimestamp, current_timestamp;
timestamp | now
----------------------------+-------------------------------
2008-09-14 12:54:23.768571 | 2008-09-14 12:54:23.768571+00
(1 row)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Karl Grossner 2008-09-14 23:59:44 a simple transform
Previous Message davidn 2008-09-14 10:10:09 selecting current UTC time