Skip to content

Instantly share code, notes, and snippets.

@alfonsodev
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save alfonsodev/a6242ba26af71893ba41 to your computer and use it in GitHub Desktop.

Select an option

Save alfonsodev/a6242ba26af71893ba41 to your computer and use it in GitHub Desktop.
Postgreesql timezones

By default postgres should be in UTC , show timezone; if it isn't change configuration timezone = 'UTC' in postgresq.conf

Store dates always in UTC, no mather user timezone, use AT TIME ZONE '' to convert it your query.

To know a list of valid values select * from pg_timezone_names;

to experiment : set timezone='Europe/Berlin' ; SELECT NOW(); SELECT NOW() AT TIME ZONE 'Europe/Berlin' SELECT NOW() AT TIME ZONE 'UTC'

read http://justatheory.com/computers/databases/postgresql/use-timestamptz.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment