Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mShuI-0001Bq-6N for pgsql-general@arkaria.postgresql.org; Tue, 21 Sep 2021 15:42:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mShuH-00020z-5F for pgsql-general@arkaria.postgresql.org; Tue, 21 Sep 2021 15:42:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mShuG-00020H-Sm for pgsql-general@lists.postgresql.org; Tue, 21 Sep 2021 15:42:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mShuE-00011H-T9 for pgsql-general@postgresql.org; Tue, 21 Sep 2021 15:42:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 18LFfxpF2031168; Tue, 21 Sep 2021 11:41:59 -0400 From: Tom Lane To: Adrian Klaver cc: Tim Uckun , pgsql-general Subject: Re: Timestamp with vs without time zone. In-reply-to: <2b5872f2-502d-369f-3dd6-1f7907883bfc@aklaver.com> References: <2b5872f2-502d-369f-3dd6-1f7907883bfc@aklaver.com> Comments: In-reply-to Adrian Klaver message dated "Tue, 21 Sep 2021 07:48:14 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2031166.1632238919.1@sss.pgh.pa.us> Date: Tue, 21 Sep 2021 11:41:59 -0400 Message-ID: <2031167.1632238919@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Adrian Klaver 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