public inbox for [email protected]
help / color / mirror / Atom feedFrom: hubert depesz lubaczewski <[email protected]>
To: Jonas Gassenmeyer <[email protected]>
Cc: [email protected]
Subject: Re: NOW() function in combination with SET timezone
Date: Fri, 4 Jun 2021 12:35:57 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CADH0_2XcdBxDJMqa5q59gnPzpZO_f4E6A034R1+-G21-ByB2_w@mail.gmail.com>
References: <CADH0_2XcdBxDJMqa5q59gnPzpZO_f4E6A034R1+-G21-ByB2_w@mail.gmail.com>
On Fri, Jun 04, 2021 at 09:53:20AM +0200, Jonas Gassenmeyer wrote:
> - Let's assume my client has set the timezone to Tokyo and the server is
> using UTC.
> - Even if calling NOW() and the display in my client is Tokyo time, once
> I send data to the server my timestamp would get converted to the timezone
> of the server.
Assuming you're talking about timestamptz - value on disk is in UTC.
> - For further comparison with any time stamp columns in a table it would
> use the converted timestamp (UTC timezone of the database server).
> - It would not make a difference if I compare NOW() to a column of type
> timestamp instead of timestampTZ (assuming that I know what timezone was
> used to insert into the column)
If you ensured that you always make conversion to utc, and store utc,
then yes. But then - you will be on your own with calculations of things
like daylight savings time.
timestamptz doesn't store time zone information, but makes sure that
when you enter data it is converted to common TZ, and then does
conversion to user timezone (which can be based on server timezone) on
select.
depesz
view thread (3+ messages) latest in thread
reply
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: NOW() function in combination with SET timezone
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox