pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: raf <raf@raf.org>
To: pgsql-general@lists.postgresql.org
Subject: Re: timestamp and timestamptz
Date: Thu, 16 Apr 2020 18:23:05 +1000
Message-ID: <20200416082305.ng2op5jybjop6pbt@raf.org> (raw)
In-Reply-To: <CAKE1AiY5mYn0=5oacokv5HC=nX+XM+YmTQpud4VHzRYan-mEtA@mail.gmail.com>
References: <4757e6ae98474a2897b2fac202466e5e@dst.dk>
	<87pnc8ieqa.fsf@gmail.com>
	<20200415235314.ciyqbyikap37ymyr@raf.org>
	<CAKFQuwYFTT0BRhBtOai--mEjns0AaB5sNzL5hbhtwCjCARB86Q@mail.gmail.com>
	<20200416071908.atryarqqqanmun7d@raf.org>
	<CAKE1AiY5mYn0=5oacokv5HC=nX+XM+YmTQpud4VHzRYan-mEtA@mail.gmail.com>

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








view thread (14+ messages)  latest in thread

Message-ID: <20200416082305.ng2op5jybjop6pbt@raf.org>
Permalink:  ../20200416082305.ng2op5jybjop6pbt@raf.org/
Also on:    postgresql.org/message-id/20200416082305.ng2op5jybjop6pbt@raf.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: raf@raf.org
  Subject: Re: timestamp and timestamptz
  In-Reply-To: <20200416082305.ng2op5jybjop6pbt@raf.org>
  References: <4757e6ae98474a2897b2fac202466e5e@dst.dk> <87pnc8ieqa.fsf@gmail.com> <20200415235314.ciyqbyikap37ymyr@raf.org> <CAKFQuwYFTT0BRhBtOai--mEjns0AaB5sNzL5hbhtwCjCARB86Q@mail.gmail.com> <20200416071908.atryarqqqanmun7d@raf.org> <CAKE1AiY5mYn0=5oacokv5HC=nX+XM+YmTQpud4VHzRYan-mEtA@mail.gmail.com> <20200416082305.ng2op5jybjop6pbt@raf.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox