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 1vMbds-00EU6P-24 for pgsql-general@arkaria.postgresql.org; Sat, 22 Nov 2025 00:38:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vMbdr-00AGDp-0G for pgsql-general@arkaria.postgresql.org; Sat, 22 Nov 2025 00:38:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vMbdq-00AGDg-08 for pgsql-general@lists.postgresql.org; Sat, 22 Nov 2025 00:38:19 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vMbdm-000oPz-25 for pgsql-general@postgresql.org; Sat, 22 Nov 2025 00:38:17 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id 80DD41D000FF; Fri, 21 Nov 2025 19:38:11 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Fri, 21 Nov 2025 19:38:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1763771891; x=1763858291; bh=wtj7yZIYA8qPfrNFhAxt0G537bokLwJGTPTmEkt/5cU=; b= UOZACwf1X37+oCIjPpk5qLko5ONXTq99Dav6+OgGMhAHplcE7TnvRj9gaYzvBsb0 StwTdmwYlEOKhhRFJKXYjI95K+ImWmgBHJl8LTIaNvIr5cqEmnPQ83x8MQ3YcnnT UKhkDF6IB/uICHrqEfwWfv3IgnGaM/eh2F/fWousUakFBN4w8GZT3YNhLopI7KMe AzOpDq3kmZ1+HHi6wCbdT87dJbvHZfGw7tRHstHJhtG1bhlpSPOw61jn00gxS7FT v40FCTfD/ruqbPFfErIvhbBnfd2kXipky2CZVK4jaBokyBVM7O3rHBnnbY24VSUE G64Sdv2cFeuBvImTh0m3QQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1763771891; x=1763858291; bh=w tj7yZIYA8qPfrNFhAxt0G537bokLwJGTPTmEkt/5cU=; b=hPhBAmyS+CAzT5y6S xYzTtVORDPLBuPWwKTYshkX9uBZG/NoWcLVSZtD9friLGzJBsBEgLeDDiwnbKWxf 33+Ed2b37ks5njCx5DFhaA0sVKryth2kXt49skmYUjT6BECHWoL+d/5pFkhpoeVu emyx40wrHimoqtNCfcFWkDspmjpSLx0SeH7m5LZXTUKOsn7ojvDNnrGs56HlXmEJ exoKYmaiw7V/UnGLwBsVLPai+v+g9jkZfuRVEe3JkMRtJJD9KDybv1Lmj0evc8qO SIDwZYIPXgEJmyVypZQkIBjDC9I/KDflgYlwBzsMeJ/GRTvuh7nru9algpdW4Dpc V+FiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvfedugedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghn ucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqe enucggtffrrghtthgvrhhnpeelgeevkeekkeeuiefgtdevieeluefhfedufeetkeejffek jeeujeehgeehgeektdenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhoug gvpehsmhhtphhouhhtpdhrtghpthhtohepshgtrhgrfihfohhrugesphhinhhpohhinhht rhgvshgvrghrtghhrdgtohhmpdhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlhesph hoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 21 Nov 2025 19:38:10 -0500 (EST) Message-ID: Date: Fri, 21 Nov 2025 16:38:10 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Unexpected date conversion results To: Steve Crawford , PG-General Mailing List References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/21/25 16:09, Steve Crawford wrote: > Either there is a bug in my understanding or one in PostgreSQL. I expect > a date value to follow the current time zone setting and be interpreted > as midnight at the start of the given date. In many cases it does. Shown > below are the postgresql.conf settings and the psql client settings > showing the time zone to be America/Los_Angeles: > > postgresql.conf: > log_timezone = 'America/Los_Angeles' > timezone = 'America/Los_Angeles' > > Client time zone setting: > > steve=> show timezone; >       TimeZone > --------------------- >  America/Los_Angeles > > > However, extracting the epoch from current_date returns 4pm the prior > day (i.e. 2025-11-21 00:00:00-00), in other words midnight 2025-11-21 > UTC which seems to be inconsistent behavior: https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT "epoch For timestamp with time zone values, the number of seconds since 1970-01-01 00:00:00 UTC (negative for timestamps before that); for date and timestamp values, the nominal number of seconds since 1970-01-01 00:00:00, without regard to timezone or daylight-savings rules; for interval values, the total number of seconds in the interval " So epoch is in UTC which is confirmed by below. > > steve=> select to_timestamp(extract(epoch from current_date)); >       to_timestamp > ------------------------ >  2025-11-20 16:00:00-08 If you want it to work(I am in 'America/Los_Angeles' also): select to_timestamp(extract(epoch from current_date)) at time zone 'UTC'; timezone --------------------- 2025-11-21 00:00:00 > There was a time, like version 9-dot-something, when the above queries > performed as expected returning midnight in the current time zone but I > haven't been able to find a change document indicating this as an > expected change. I don't remember that, but as the gray content of the hair increases the memory is less solid:) > > -Steve -- Adrian Klaver adrian.klaver@aklaver.com