Re: time zone problem

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Cefull Lo <cefull(at)gmail(dot)com>
Subject: Re: time zone problem
Date: 2012-01-16 15:28:59
Message-ID: 201201160728.59702.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, January 16, 2012 5:50:42 am Cefull Lo wrote:
> Hi,
> I figure it out.
> If only the offset from UTC is given, you may try
>
> select current_timestamp at time zone (select name from
> pg_catalog.pg_timezone_names where utc_offset= interval '+8 hours' limit 1)
>
> Would give the exact timestamp at those time zone.

This assumes the current_timestamp is being run against a server that has
timezone with no DST component. If not the answer will be different when DST is
in effect versus when it is not. Remember a timezone has an offset , but an offset
is not any given timezone.

To illustrate using your example above without the limit:

test(5432)postgres=#select name from pg_catalog.pg_timezone_names where
utc_offset= interval '+8 hours';
name
--------------------
Antarctica/Casey
Asia/Brunei
Asia/Harbin
Asia/Shanghai
Asia/Chongqing
Asia/Urumqi
Asia/Kashgar
Asia/Hong_Kong
Asia/Taipei
Asia/Macau
Asia/Makassar
Asia/Kuala_Lumpur
Asia/Kuching
Asia/Ulaanbaatar
Asia/Choibalsan
Asia/Manila
Asia/Singapore
Asia/Krasnoyarsk
Asia/Chungking
Asia/Macao
Asia/Ujung_Pandang
Asia/Ulan_Bator
Australia/Perth
Australia/West
Etc/GMT-8
Hongkong
PRC
ROC
Singapore

>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-01-16 15:52:06 Re: time zone problem
Previous Message Tomas Vondra 2012-01-16 15:08:29 Re: Getting all entries in a single block with ctid