From: Gary Bernhardt <gary.bernhardt@gmail.com>
To: pgsql-bugs@lists.postgresql.org
Subject: Converting to UTC multiple times converts back to local time zone
Date: Mon, 25 Jun 2018 16:47:53 -0700
Message-ID: <1529970473.36096.1420218376.3C13DF11@webmail.messagingengine.com> (raw)
now() is local, as I expect:
testdb=# select now();
2018-06-25 16:41:28.037072-07
And converting to UTC does convert to UTC:
testdb=# select now() at time zone 'utc';
2018-06-25 23:41:23.700795
But converting that timestamp to UTC a second time converts back to
local:
testdb=# select (now() at time zone 'utc') at time zone 'utc';
2018-06-25 16:43:03.200762-07
This seems to happen regardless of where the UTC timestamp comes from.
Here's the same thing done with a subquery:
testdb=# select (ts at time zone 'utc') from (select now() at time zone
'utc' as ts) as t1;2018-06-25 16:44:05.219322-07
This seems very wrong to me. But this also seems like something that
would have been exercised many, many times in the wild.
I'd expect "converting" a UTC timestamp to UTC would keep it in UTC. Am
I missing something?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: gary.bernhardt@gmail.com
Subject: Re: Converting to UTC multiple times converts back to local time zone
In-Reply-To: <1529970473.36096.1420218376.3C13DF11@webmail.messagingengine.com>
References: <1529970473.36096.1420218376.3C13DF11@webmail.messagingengine.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox