Re: Thoroughly confused about time zones

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Rob Richardson <Rob(dot)Richardson(at)rad-con(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Thoroughly confused about time zones
Date: 2011-02-28 19:30:08
Message-ID: 20110228193008.GB26061@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 28, 2011 at 10:06:28AM -0500, Rob Richardson wrote:
> Our application stores the times at which several events happened, and
> we need to be able to calculate the elapsed time between events.
> Currently, the times are stored as timestamps without time zone, in both
> local and UTC times. Elapsed time calculations are based on the UTC
> times. Supposedly, that should avoid problems posed by the change from
> standard to daylight savings time, but it is not working out that easily
> in practice.

A useful way I find of thinking about it is: you have two things you
want to be able to store.

- An instant in time, an event for example. The representation of this
instant is dependant on where you are. This is the timestamp with
time zone.

- The wall clock time, what it say on the wall. So, no time zone, it
just represents what a clock said at some point. This is the
timestamp without time zone.

The latter is usually not that useful, except for output. What you
usually want is the timestamptz.

Hop this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patriotism is when love of your own people comes first; nationalism,
> when hate for people other than your own comes first.
> - Charles de Gaulle

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2011-02-28 19:37:37 Re: regexp problem
Previous Message Jason Long 2011-02-28 19:18:33 Re: Full Vacuum/Reindex vs autovacuum