Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the list of timezones supported by PostgreSQL?

Tags:

postgresql

The question is pretty self-explanatory. I found this documentation here:

https://www.postgresql.org/docs/current/view-pg-timezone-names.html

However, it does not really mention how to get a list of all the supported timezones. How can I do this?

like image 341
darkhorse Avatar asked Jan 02 '19 01:01

darkhorse


3 Answers

The answer from Tim was excellent. For whatever reason my Postgres DB also contained a bunch of fluff with the prefix "posix/" and I also needed these in alphabetical order to use on a website, so I did this:

SELECT
    name,
    abbrev,
    utc_offset,
    is_dst
FROM pg_timezone_names 
WHERE name !~ 'posix' 
ORDER BY name asc;
like image 113
Deminetix Avatar answered Oct 11 '22 01:10

Deminetix


You may try selecting from the view pg_timezone_names, as the documentation says:

The view pg_timezone_names provides a list of time zone names that are recognized by SET TIMEZONE, along with their associated abbreviations, UTC offsets, and daylight-savings status.

Try the following query:

SELECT
    name,
    abbrev,
    utc_offset,
    is_dst
FROM pg_timezone_names;
like image 44
Tim Biegeleisen Avatar answered Oct 10 '22 23:10

Tim Biegeleisen


I ran this query and pasted the results here if anybody wants to save the time of running it themselves.

like image 1
wbharding Avatar answered Oct 10 '22 23:10

wbharding