How to get the time zone offset using to_char

From: Cezariusz Marek <cezariusz(dot)marek(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to get the time zone offset using to_char
Date: 2011-12-30 11:39:21
Message-ID: CANRnGAZ8GGG_Hkh0CAK1yq-Uf5BC-GMuBpZCEk0BfO_txxcOuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to convert timestamp to a format with a time zone offset, like this:

select clock_timestamp()::text;

which returns:

"2011-12-30 11:59:06.538+01"

What is the default format for timestamp::text conversion? I've tried this:

select to_char(clock_timestamp(), 'YYYY-MM-DD HH24:MI:SSTZ');

But it gives me "CET" instead of "+01":

"2011-12-30 11:59:06CET"

--
Cezariusz Marek http://midicat.net/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2011-12-30 12:03:08 Re: streaming replication vacuum
Previous Message Cezariusz Marek 2011-12-30 11:22:48 How to get the time zone offset using to_char