3

This question already has an answer here:

Why is there a difference between named timezone and numeric timezone offset, both of which yield different UTC timestamps for TIMESTAMPTZ?

Assume Europe/Prague timezone, which is currently +02:00 (DST); time of writing is 2018-08-25.

As you can check e.g. via google:

uploaded image

Also, in my postgres installation I can query it:

SELECT utc_offset FROM pg_timezone_names where name = 'Europe/Prague';

Which also yields 02:00:00.

Then, why on earth, do I get two different UTC timestamps when running following two queries?

The following yields 2018-08-25T20:00:00.000Z (2018-08-25 18:00:00-02):

SET TIME ZONE '+02:00'; -- with or without the plus
SELECT '2018-08-25 18:00:00'::TIMESTAMPTZ;

The following yields 2018-08-25T16:00:00.000Z (2018-08-25 18:00:00+02), which is correct:

SET TIME ZONE 'Europe/Prague';
SELECT '2018-08-25 18:00:00'::TIMESTAMPTZ;

Why does postgres differentiate those two notations?

marked as duplicate by Evan Carroll postgresql Aug 26 '18 at 2:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    DST (daylight saving time) changes according to countries. For example, 2 different countries with same offset but one uses DST and the other does not. – Sahap Asci Aug 25 '18 at 22:11
1

Because, as documented, one uses POSIX and other uses ISO-8601.

Another issue to keep in mind is that in POSIX time zone names, positive offsets are used for locations west of Greenwich. Everywhere else, PostgreSQL follows the ISO-8601 convention that positive timezone offsets are east of Greenwich.

  • But docs say that POSIX is in format STDoffset, so +02:00 shouldn't be POSIX, which is corroborated by docs here, which say that it's ISO-8601. Then why does it result in -02 UTC offset, which is incorrect (my first example in OP)? – dwelle Aug 26 '18 at 7:54
  • Accepting since you're right, but I made a follow-up question, to figure out why this is so. – dwelle Aug 26 '18 at 12:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.