Skip to content

Instantly share code, notes, and snippets.

@kurdin
Forked from prestonp/pg-change-timezone.md
Created June 8, 2022 20:39
Show Gist options
  • Save kurdin/76f01d7b328b21944868c9f7324ba977 to your computer and use it in GitHub Desktop.
Save kurdin/76f01d7b328b21944868c9f7324ba977 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