Skip to content

Instantly share code, notes, and snippets.

@davetapley
Last active August 29, 2015 14:01
Show Gist options
  • Save davetapley/a6b032934c2136982789 to your computer and use it in GitHub Desktop.
Save davetapley/a6b032934c2136982789 to your computer and use it in GitHub Desktop.
test=# CREATE TABLE tzs(with_tz TIMESTAMP WITH TIME ZONE, without_tz TIMESTAMP WITHOUT TIME ZONE, comment TEXT);
CREATE TABLE
test=# INSERT INTO tzs VALUES( now(), now(), 'now()');
test=# INSERT INTO tzs VALUES( timezone('America/New_York', now()), timezone('America/New_York', now()), 'timezone(New York, now())');
INSERT 0 1
test=# INSERT INTO tzs VALUES( '2014-05-06T17:14:00Z', '2014-05-06T17:14:00Z', 'ISO 8601 Zulu' );
INSERT 0 1
test=# INSERT INTO tzs VALUES( '2014-05-06T17:14:00-04:00', '2014-05-06T17:14:00-04:00', 'ISO 8601 offset' );
INSERT 0 1
test=# SELECT * FROM tzs ;
with_tz | without_tz | comment
-------------------------------+----------------------------+---------------------------
2014-05-07 00:16:22.193127+00 | 2014-05-07 00:16:22.193127 | now()
2014-05-06 20:16:47.791742+00 | 2014-05-06 20:16:47.791742 | timezone(New York, now())
2014-05-06 17:14:00+00 | 2014-05-06 17:14:00 | ISO 8601 Zulu
2014-05-06 21:14:00+00 | 2014-05-06 17:14:00 | ISO 8601 offset
(4 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment