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 1kugjG-0004g9-Mf for pgsql-bugs@arkaria.postgresql.org; Wed, 30 Dec 2020 19:01:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kugjF-0006Rf-CW for pgsql-bugs@arkaria.postgresql.org; Wed, 30 Dec 2020 19:01:49 +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 1kugjF-0006RY-6Q for pgsql-bugs@lists.postgresql.org; Wed, 30 Dec 2020 19:01:49 +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 1kugjA-0000iY-8B for pgsql-bugs@lists.postgresql.org; Wed, 30 Dec 2020 19:01:48 +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 0BUJ1gPk2396655; Wed, 30 Dec 2020 14:01:42 -0500 From: Tom Lane To: djburd@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16797: EXTRACT(EPOCH FROM timestamp) is not using local timezone In-reply-to: <16797-f264b0b980b53b8b@postgresql.org> References: <16797-f264b0b980b53b8b@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 30 Dec 2020 17:10:17 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2396653.1609354902.1@sss.pgh.pa.us> Date: Wed, 30 Dec 2020 14:01:42 -0500 Message-ID: <2396654.1609354902@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > EXTRACT(EPOCH FROM timestamp) should be using the local timezone No, type timestamp is explicitly *not* timezone aware. If you use timestamptz (a/k/a timestamp with time zone) you will get the answer you want. > -- Expected results (seen from PostgreSQL 9.1.11): > # SET TIME ZONE 'EST5EDT'; select extract(epoch from ('01/01/1970 > 00:00:00'::timestamp)); This was a bug, cf 9.2.0 release notes [1]: Make EXTRACT(EPOCH FROM timestamp without time zone) measure the epoch from local midnight, not UTC midnight (Tom Lane) This change reverts an ill-considered change made in release 7.3. Measuring from UTC midnight was inconsistent because it made the result dependent on the timezone setting, which computations for timestamp without time zone should not be. The previous behavior remains available by casting the input value to timestamp with time zone. regards, tom lane [1] https://www.postgresql.org/docs/release/9.2.0/