Created
March 19, 2020 21:56
-
-
Save jamesbursa/2b5204b3f914431734d9aadd3d15846a to your computer and use it in GitHub Desktop.
PostgreSQL TIMESTAMPs and time zones
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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