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 1jOznm-0003jc-PB for pgsql-general@arkaria.postgresql.org; Thu, 16 Apr 2020 08:23:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jOznl-0004qT-Ns for pgsql-general@arkaria.postgresql.org; Thu, 16 Apr 2020 08:23:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jOznl-0004qM-Et for pgsql-general@lists.postgresql.org; Thu, 16 Apr 2020 08:23:13 +0000 Received: from ook.raf.org ([139.99.156.21]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jOzng-0003c5-V3 for pgsql-general@lists.postgresql.org; Thu, 16 Apr 2020 08:23:13 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id 207FF5DE30 for ; Thu, 16 Apr 2020 18:23:06 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at ook.raf.org Received: from ook.raf.org ([127.0.0.1]) by localhost (ook.raf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UbQ5eTrLM_ce for ; Thu, 16 Apr 2020 18:23:05 +1000 (AEST) Received: by ook.raf.org (Postfix, from userid 1001) id E77565E28D; Thu, 16 Apr 2020 18:23:05 +1000 (AEST) Date: Thu, 16 Apr 2020 18:23:05 +1000 From: raf To: pgsql-general@lists.postgresql.org Subject: Re: timestamp and timestamptz Message-ID: <20200416082305.ng2op5jybjop6pbt@raf.org> References: <4757e6ae98474a2897b2fac202466e5e@dst.dk> <87pnc8ieqa.fsf@gmail.com> <20200415235314.ciyqbyikap37ymyr@raf.org> <20200416071908.atryarqqqanmun7d@raf.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Steve Baldwin wrote: > I'm pretty sure you are mistaken. Postgres doesn't store the 'creating' > time zone in a timestamptz column. > > Try doing this before re-running your test: > > set timezone to 'utc'; > > What you are seeing in your test is an artifact of that timezone setting. > > Steve Thanks. You're right. create table example (t timestamptz not null); insert into example (t) values (timestamptz '2020-04-16 17:12:33.71768 Australia/Sydney'); select * from example; set timezone to 'utc'; select * from example; drop table example; Does this: CREATE TABLE INSERT 0 1 t ------------------------------ 2020-04-16 17:12:33.71768+10 (1 row) SET t ------------------------------ 2020-04-16 07:12:33.71768+00 (1 row) DROP TABLE So it doesn't store the offset, but I've used postgres for 12 years without knowing that and it hasn't been a problem. Yay, postgres! It doesn't store the offset but, by using timestamptz, it knows that the timezone is UTC. That's what matters. The fact that it knows the time zone is what makes everything work. Timestamp without time zone is best avoided I think. cheers, raf