Re: Changing displayed time zone in RAISE NOTICE output?

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Changing displayed time zone in RAISE NOTICE output?
Date: 2023-01-12 05:25:55
Message-ID: 6a7ddac2-48e1-7339-5919-a69d6d7801ae@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/11/23 15:06, Adrian Klaver wrote:
> On 1/11/23 13:00, Ron wrote:
>> How do I get clock_timestamp() to display the time in a different time zone?
>>
>> This is America/Chicago, but I'd like to display it in a different TZ.
>>
>> psql (12.12 (Ubuntu 12.12-1.pgdg18.04+1))
>> postgres=# DO $$
>> postgres$# BEGIN
>> postgres$# RAISE NOTICE '%', clock_timestamp();
>> postgres$# END$$;
>> NOTICE:  2023-01-11 14:52:34.408225-06
>> DO
>>
>
> test(5432)=# select clock_timestamp();
>         clock_timestamp
> --------------------------------
>  01/11/2023 13:05:54.646178 PST
> (1 row)
>
> test(5432)=# select clock_timestamp() at time zone 'UTC';
>           timezone
> ----------------------------
>  01/11/2023 21:06:04.742478

Hmm.  I'd have sworn this didn't work when I tried it:

postgres=#
postgres=# DO $$
BEGIN
RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
END$$;
NOTICE:  2023-01-12 05:22:40.517299

But it does work, so all's well that ends well.

--
Born in Arizona, moved to Babylonia.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2023-01-12 05:42:04 EXPLAIN and FK references?
Previous Message Tom Lane 2023-01-11 21:07:00 Re: Autovacuum Hung Due to Bufferpin