Skip to content

Instantly share code, notes, and snippets.

@jamesbursa
Created March 19, 2020 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesbursa/2b5204b3f914431734d9aadd3d15846a to your computer and use it in GitHub Desktop.
Save jamesbursa/2b5204b3f914431734d9aadd3d15846a to your computer and use it in GitHub Desktop.
PostgreSQL TIMESTAMPs and time zones
james=> SHOW TimeZone;
TimeZone
------------------
America/New_York
(1 row)
james=> CREATE TEMPORARY TABLE test (t TIMESTAMP WITH TIME ZONE);
CREATE TABLE
james=> INSERT INTO test VALUES ('2020-03-20 12:30:00 America/New_York'), ('2020-03-20 15:30:00 Europe/London');
INSERT 0 2
james=> SELECT * FROM test;
t
------------------------
2020-03-20 12:30:00-04
2020-03-20 11:30:00-04
(2 rows)
james=> SET TIME ZONE 'UTC';
SET
james=> SELECT * FROM test;
t
------------------------
2020-03-20 16:30:00+00
2020-03-20 15:30:00+00
(2 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment