Skip to content

Instantly share code, notes, and snippets.

@prestonp
Last active October 21, 2022 16:26
Show Gist options
  • Save prestonp/b2c0bd9a450ca8df3cca to your computer and use it in GitHub Desktop.
Save prestonp/b2c0bd9a450ca8df3cca to your computer and use it in GitHub Desktop.
Change timezone in pg

Changing timezone in postgres

To change your server’s timezone per session you can use the following query:

set timezone TO 'GMT';

If you need to permanently update the timezone, find your postgresql.conf file in psql:

preston=# show config_file;

config_file

/Users/preston/Library/Application Support/Postgres/var-9.3/postgresql.conf (1 row) 

Inside of postgresql.conf change your timezone

timezone = ‘US/Central’;

to

timezone = ‘UTC’; 

Save and restart postgres.

Confirm the timezone is changed via

preston=# select current_setting(‘timezone’);

current_setting

GMT (1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment