Re: Convert from unixtime? - Mailing list pgsql-novice

From Tom Lane
Subject Re: Convert from unixtime?
Date
Msg-id 772.1048350089@sss.pgh.pa.us
Whole thread Raw
In response to Re: Convert from unixtime?  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-novice
Bruno Wolff III <bruno@wolff.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


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] Just to ascertain why my posts are going astray
Next
From: Ennio Iannucci
Date:
Subject: Extended display and extended ascii characters