I have several PostgreSQL 9.2 installations where the timezone used by PostgreSQL is GMT, despite the entire system being "Europe/Vienna". I double-checked that postgresql.conf
does not contain timezone
setting, so according to the documentation it should fallback to the system's timezone.
However,
# su -s /bin/bash postgres -c "psql mydb"
mydb=# show timezone;
TimeZone
----------
GMT
(1 row)
mydb=# select now();
now
-------------------------------
2013-11-12 08:14:21.697622+00
(1 row)
Any hints, where the GMT timezone could come from? The system user does not have TZ
set and the /etc/timezone
and /etc/timeinfo
seem to be configured correctly.
# cat /etc/timezone
Europe/Vienna
# date
Tue Nov 12 09:15:42 CET 2013
Any hints are appreciated, thanks in advance!
The default value for the
TimeZone
setting has changed on release 9.2:TimeZone
:TimeZone
:Which means that prior to version 9.2 the default value at
postgresql.conf
should be set duringinitdb
phase. If you overridden that value (probably copying the oldpostgresql.conf
while upgrading from older versions) PostgreSQL will use the "GMT" value as default.The solution for your case is quite simple, just change the
TimeZone
setting onpostgresql.conf
to the value you want:After that you need to
reload
the service:Then all fields stored as
timestamp with time zone
(ortimestamptz
) will be shown correctly from now on. But you will have to correct by hand all (update) the fields stored astimestamp without time zone
(ortimestamp
).A tip I give to everyone upgrading PostgreSQL is not to copy the old
postgresql.conf
to the new cluster (notice I'm not sure if it what you did, but I saw this very same problem a lot because of that). Just get the one generated byinitdb
and add the modifications (adiff
tool may be handful to this task).I found a workaround for this.
just create a symlink inside /usr/share/zoneinfo/ named localtime (or whatever name you wish) to be pointing at /etc/localtime
this way you're creating a string of links that ultimately points at your system's timezone.
Now take the name of the link you created (localtime in my case) and use it as the value of the configuration item in postgresql.conf
restart postgresql and check the time with "SELECT now();" and "show timezone;"