Re: TimeZone parameter in postgresql.conf

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Majid Azimi <majid(dot)merkava(at)gmail(dot)com>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: TimeZone parameter in postgresql.conf
Date: 2012-09-05 18:56:14
Message-ID: 5047A04E.9090007@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 09/05/2012 11:03 AM, Majid Azimi wrote:
>
> postgresql documentation says:
>
> All timezone-aware dates and times are stored internally in UTC.
> They are converted to local time in the zone specified by the
> timezone configuration parameter before being displayed to the client.
>
> timezone parameter is a session parameter
> <http://www.postgresql.org/docs/9.1/static/runtime-config-client.html#GUC-TIMEZONE>.
> When all |TIMESTAMP WITH TIME ZONE|s will be stored as |UTC| and the
> client connection will specify the session timezone, then what is the
> benefit of setting TimeZone parameter in postgresql.conf?
>
http://www.postgresql.org/docs/9.1/static/datatype-datetime.html#DATATYPE-TIMEZONES:

...

The timezone
<http://www.postgresql.org/docs/9.1/static/runtime-config-client.html#GUC-TIMEZONE>
configuration parameter can be set in the file postgresql.conf, or in
any of the other standard ways described in Chapter 18
<http://www.postgresql.org/docs/9.1/static/runtime-config.html>. There
are also several special ways to set it:

*

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
<http://www.postgresql.org/docs/9.1/static/runtime-config-logging.html#GUC-LOG-TIMEZONE>,
if not specified.)

*

The SQL command SET TIME ZONE sets the time zone for the session.
This is an alternative spelling of SET TIMEZONE TO with a more
SQL-spec-compatible syntax.

*

The PGTZ environment variable is used by libpq clients to send a SET
TIME ZONE command to the server upon connection.

...

In other words is is an explicit default time zone but like many other
defaults specified in postgresql.conf you can override it in a session.

Cheers,
Steve

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message lmanorders 2012-09-05 21:59:55 How to determine if a function exists
Previous Message Majid Azimi 2012-09-05 18:03:11 TimeZone parameter in postgresql.conf