Обсуждение: How to get TimeZone name?

Поиск
Список
Период
Сортировка

How to get TimeZone name?

От
araza@esri.com
Дата:
Hi,

How can I get timezone name? I can get timezone offset but I could not find any reference of timezone name.

pg_timezone_names does not provide information I am looking for. For example, my system's time zone is set to '
US/Pacific'.If I select timezone name for the offset '-08:00:00' then I do not get what I am expecting.  

I have a default setting for timezone and lc_time in my postgresql.conf file.

1-
sde10=> Select current_timestamp - current_timestamp AT TIME ZONE 'UTC' As TimeZoneOffSet;
 timezoneoffset
----------------
 -08:00:00
(1 row)


2-
sde10=> select * from pg_timezone_names where utc_offset = '-08:00:00';
        name         | abbrev | utc_offset | is_dst
---------------------+--------+------------+--------
 America/Dawson      | PST    | -08:00:00  | f
 America/Ensenada    | PST    | -08:00:00  | f
 America/Los_Angeles | PST    | -08:00:00  | f
 America/Tijuana     | PST    | -08:00:00  | f
 America/Vancouver   | PST    | -08:00:00  | f
 America/Whitehorse  | PST    | -08:00:00  | f
 Canada/Pacific      | PST    | -08:00:00  | f
 Canada/Yukon        | PST    | -08:00:00  | f
 Etc/GMT+8           | GMT+8  | -08:00:00  | f
 Mexico/BajaNorte    | PST    | -08:00:00  | f
 Pacific/Pitcairn    | PST    | -08:00:00  | f
 PST8PDT             | PST    | -08:00:00  | f
 US/Pacific          | PST    | -08:00:00  | f
 US/Pacific-New      | PST    | -08:00:00  | f
(14 rows)


Thanks.

Ale

Re: How to get TimeZone name?

От
Jasen Betts
Дата:
On 2011-01-18, araza@esri.com <araza@esri.com> wrote:
> Hi,
>
> How can I get timezone name?
> I can get timezone offset but I could not find any reference of timezone name.

Change your datestyle setting, a setting of ISO gives nice portable
offsets that will work the same anywhere in the world.
a setting of SQL gives a locale-dependant rendering that looks nice
but is often ambiguous

> 1-
> sde10=> Select current_timestamp - current_timestamp AT TIME ZONE 'UTC' As TimeZoneOffSet;
>  timezoneoffset
> ----------------
>  -08:00:00
> (1 row)

What do you think the above is doing?


Is the following of any use to you?

set datestyle to 'sql,mdy';
select current_timestamp;


--
⚂⚃ 100% natural