Skip to content

Instantly share code, notes, and snippets.

@hiepndd
Forked from Hazem-Ben-Khalfallah/timeZone.sql
Created July 14, 2020 09:05
Show Gist options
  • Save hiepndd/51ef0e4a5e3ce0c7d7c395e87f2a3ef0 to your computer and use it in GitHub Desktop.
Save hiepndd/51ef0e4a5e3ce0c7d7c395e87f2a3ef0 to your computer and use it in GitHub Desktop.
[Timezone in postgresql] get and set timezone in #postgresql #sql
-- timezone abrev list
select * from pg_timezone_names ;
-- set timezone TO 'pg_timezone_names.name'
set timezone TO 'posix/Africa/Tunis'; --(GMT+01)
set timezone TO 'GMT'; --(UTC/GMT)
-- read current timezone:
SELECT current_setting('TIMEZONE')
--reset timezone for database
alter database DATABASE_NAME set timezone TO 'posix/Africa/Tunis'; --(GMT+01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment