Re: Convert from unixtime?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Forjan Tamas <tamas(at)2fkft(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Convert from unixtime?
Date: 2003-03-22 16:21:29
Message-ID: 772.1048350089@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> select 1::abstime::timestamp with time zone;
> or
> select 1::abstime::timestamp with time zone at time zone 'GMT'::timestamp;

> Depending on whether or not you want a time zone associated with the
> timestamp. Note that if you go directly from abstime to timestamp
> (without time zone), then the time will be off by your offset from GMT.

It seems to me that that case also produces sensible results:

regression=# select 1::abstime::timestamp without time zone ;
timestamp
---------------------
1969-12-31 19:00:01
(1 row)

This corresponds to my local time (EST) at unix timestamp 1, which is
exactly what timestamp without time zone ought to show.

Obviously, which of these you want to use depends on what your goal is,
but they all give useful behaviors IMHO.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tamir Halperin 2003-03-24 01:38:04 From a real novice
Previous Message Tom Lane 2003-03-22 16:08:45 Re: Just to ascertain why my posts are going astray