From the docs on 9.1, I see

If timezone is not specified in postgresql.conf or as a server command-line option, the server attempts to use the value of the TZ environment variable as the default time zone. If TZ is not defined or is not any of the time zone names known to PostgreSQL, the server attempts to determine the operating system's default time zone by checking the behavior of the C library function localtime(). The default time zone is selected as the closest match among PostgreSQL's known time zones. (These rules are also used to choose the default value of log_timezone, if not specified.)

This section was however removed subsequently in 9.2, what happens if 9.2+ is not specified in postgresql.conf or as a server command-line option?

My timezone currently says localtime and I'm wondering what exactly that means and how it's decided. The original text seems to answer it if it's still applicable. Are we still relying on the C library function localtime()?

# show timezone;
(1 row)

I was trying to add this information in this answer for completeness when I realized that the older docs had more details.

  • I'm about 95% sure it does the same thing on the server. So I'm not sure why they removed that in the docs. – Evan Carroll Jan 12 '17 at 22:36

It seems like PostgreSQL 10 still

  1. Looks at the environmental variable TZ first
  2. Proceeds to use the localtime library function.
  3. Looks under the shared directory or the system directory for matching timezone information.

So it seems like the 9.1 docs are still accurate as of PostgreSQL 10.

Internally, you can see the list of timezone information by using SELECT * FROM pg_timezone_names(); (here in the source) which calls pg_tzenumerate_start which the reads the shared directory or system directory above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.