Tuesday, April 12, 2016

Postgresql: Changing timezone

Application getting incorrect timezone and suspecting it came from the Postgresql database. Default/Global timezone can be easily changed from postgresql.conf without the need to bounce the database.


1- Check current timezone.
vcdb5=> show timezone;
  TimeZone 
------------
 US/Pacific
(1 row)


2- Check postgresql.conf. Search for "timezone" keyword. 
[postgres@localhost data]$ grep "timezone" postgresql.conf
log_timezone = 'US/Pacific'
timezone = 'US/Pacific'


3- Change timezone to ‘Europe/Vienna’ in the postgresql.conf
timezone ='Europe/Vienna'


4- Reload the conf file from psql 
postgres=# SELECT pg_reload_conf();
 pg_reload_conf
----------------
 t
(1 row)


5- Show the timezone and it is flipped.
postgres=# show timezone;
   TimeZone   
---------------
 Europe/Vienna
(1 row)

No comments:

Post a Comment