Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wNXpl-000tQi-3A for pgsql-docs@arkaria.postgresql.org; Thu, 14 May 2026 15:18:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wNXpk-00DJhI-2Y for pgsql-docs@arkaria.postgresql.org; Thu, 14 May 2026 15:18:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wMzDx-006kk8-38 for pgsql-docs@lists.postgresql.org; Wed, 13 May 2026 02:21:26 +0000 Received: from mx2.mythic-beasts.com ([2a00:1098:0:82:1000:0:2:1]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wMzDt-00000000Icz-2pte for pgsql-docs@lists.postgresql.org; Wed, 13 May 2026 02:21:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=richardneill.org; s=mythic-beasts-k1; h=Subject:To:From:Date; bh=alpeOfRlPUdyYzUQzH937vzZbLBKVMQhLBPDb4TfhTM=; b=rF6oAmJSPcbHNuna13YvvDAkYO IOPPFk9gn6vL13psIZLCLDrQtfrcx64LxJJPLGWVTeFr0TjAKLAeFXfZg9oro6w1jXsP3tecqEPoa otnffXsw3URO84xJK2wtqLUVYh7+Ckd53z4u7+X0OWzxA0/vGs+XNdGlXVCzgenJhkHcrXUoqo3A3 FdOl6qLFlCztYtaOFX6uT/WHOVn/4E+o1CftjlGUG4m5ueEX1TDPI1WV3vqs9BpXm1cfom6P8LeyO ga4+FIxklQvn3lukC6O7j9PJugjCVn2MngHPjsIjV9JtzzS6xEZcbWet1hYGhEX2ULtbLTzu9tIQ1 FC/haaqg==; Received: by mailhub-hex-d.mythic-beasts.com with esmtpa (Exim 4.96) (envelope-from ) id 1wMzDq-00FV6s-2E; Wed, 13 May 2026 03:21:18 +0100 MIME-Version: 1.0 Date: Wed, 13 May 2026 03:21:11 +0100 From: Richard Neill To: Bruce Momjian Cc: github@richardneill.org, pgsql-docs@lists.postgresql.org Subject: Re: Please clarify that Timestamp with Timezone doesn't preserve the timezone. In-Reply-To: References: <177685804902.403059.7237129094698721575@wrigleys.postgresql.org> Message-ID: X-Sender: rjn@richardneill.org X-Mailer: Mythic Beasts Webmail (https://webmail.mythic-beasts.com) X-Originating-IP: 2a00:1098:1::94 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Bruce, Thanks for your reply. Yes I think it does need to be stated more boldly - from a "Poka-Yoke" perspective (and despite using Postgresql for years), I didn't properly understand it the first time. I think it's a gotcha, because, to me, the name suggests a different behaviour. I understood "timestamp with timezone" as "a data type which stores the timestamp, and stores the timezone WITH (i.e. alongside) it". So I think it deserves a "Caution" or "note" boxout, or at least to have words "the originally stated or assumed time zone is not retained." made in bold. While looking at the docs, I can also see 3 other things that would be helpful to add: 1. How to actually store "timestamp_and_timezone" ? (i.e. I want to store the UTC value, and I want to store and retrieve the original offset). Presumably the answer is to store both timestamptz AND the integer tz_offset (is there a "timezone" datatype, or should that just be a string?) 2. How to store a general timestamp in NO timezone (for example, to store the concept that "Armistice Day is remembered at 11:00 on 11/11" - which is the same for everyone across the world, even though the underlying UTC value is undefined). Presumably you could store this as 2 columns (date, time), but there's no compound "date+time" type, and it would not be the same as timestamp. 3. While the docs caution against using "time with timezone", they don't recommend whether to use "timestamp" or "timestamptz" as the default. Such a recommendation might be helpful. Best wishes, Richard On 2026-05-13 01:19, Bruce Momjian wrote: > On Wed, Apr 22, 2026 at 11:40:49AM +0000, PG Doc comments form wrote: >> The following documentation comment has been logged on the website: >> >> Page: https://www.postgresql.org/docs/18/datatype-datetime.html >> Description: >> >> Hi, >> >> Just a small bit of feedback on this page: >> https://www.postgresql.org/docs/current/datatype-datetime.html >> >> There is a gotcha for the unwary, in that it does not preserve the >> original >> timezone after the data is recorded. >> The user needs to understand that timestamp with timezone is >> performing >> implicit conversion for them, but it does not save the TZ value. >> >> One might, naively, expect it to do the "obvious" thing, storing the >> original timezone alongside the timestamp, and therefore >> allow you to query the data and discover what the timezone was when >> the data >> was input. >> (i.e. the on-disk representation of "17th May at 4pm New York" should >> be >> different from "17th May at 1pm in Los Angeles", and that a query >> should be able to do something like not just the UTC value in the >> local >> timezone, but also the fact that this date was recorded from the >> perspective >> of a New Yorker). >> >> Or in other words, one might expect that: >> SELECT EXTRACT (timezone FROM '2026-04-16 13:00:00+09'::timestamptz); >> should be able to tell me the "+09", regardless of my own local time. >> >> May I suggest adding a "Caution" to draw greater attention to this >> fact, and >> recommending an alternative if there is one. > > The documentation says: > > https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-INPUT > > For timestamp with time zone values, an input string that > includes an explicit time zone will be converted to UTC > (Universal Coordinated Time) using the appropriate offset for > that time zone. If no time zone is stated in the input string, > then it is assumed to be in the time zone indicated by the > system's TimeZone parameter, and is converted to UTC using the > --> offset for the timezone zone. In either case, the value is stored > --> internally as UTC, and the originally stated or assumed time zone > --> is not retained. > > Does this need to be stated more boldly?