pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Tim Uckun <timuckun@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Timestamp with vs without time zone.
Date: Tue, 21 Sep 2021 11:41:59 -0400
Message-ID: <2031167.1632238919@sss.pgh.pa.us> (raw)
In-Reply-To: <2b5872f2-502d-369f-3dd6-1f7907883bfc@aklaver.com>
References: <CAGuHJrPKdrXGAFkzE4tXd3b5uKe47WCRdV3LNrYi_HBjYYa+OA@mail.gmail.com>
	<2b5872f2-502d-369f-3dd6-1f7907883bfc@aklaver.com>

Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 9/20/21 11:00 PM, Tim Uckun wrote:
>> I am hoping to get some clarification on timestamp with time zone.
>> 
>> My understanding is that timestamp with time zone stores data in UTC
>> but displays it in your time zone.  Does this also work on queries? If
>> I query between noon and 2:00 PM on some date in time zone XYZ does pg
>> translate the query to UTC before sending it to the server?
>> 
>> So does the database know the timestamp is in auckland time when the
>> client is connecting from a server on UTC?

It might be more clear if you realize that there is no client-side logic
involved here.  The rotation to/from UTC happens in timestamptz_in or
timestamptz_out, based on the server's TimeZone setting.

It's incumbent on clients to set TimeZone correctly if they want
unlabeled timestamps to be interpreted in a particular zone.

			regards, tom lane





view thread (35+ messages)  latest in thread

Message-ID: <2031167.1632238919@sss.pgh.pa.us>
Permalink:  ../2031167.1632238919@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2031167.1632238919@sss.pgh.pa.us

 · 

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 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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, timuckun@gmail.com
  Subject: Re: Timestamp with vs without time zone.
  In-Reply-To: <2031167.1632238919@sss.pgh.pa.us>
  References: <CAGuHJrPKdrXGAFkzE4tXd3b5uKe47WCRdV3LNrYi_HBjYYa+OA@mail.gmail.com> <2b5872f2-502d-369f-3dd6-1f7907883bfc@aklaver.com> <2031167.1632238919@sss.pgh.pa.us>

* 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