Re: unix timestamp - Mailing list pgsql-general

From Thomas Lockhart
Subject Re: unix timestamp
Date
Msg-id 3B7C2F88.76ED8282@fourpalms.org
Whole thread Raw
In response to unix timestamp  ("Ben-Nes Nimrod" <nimrod@canaan.co.il>)
List pgsql-general
> how can i use unix timestamp as a data type?

You don't want to. Really.

> i thought that the timestamp data type use the unix timestamp but
> found out that it didnt.. :(

Right. One second resolution and limited range was considered a problem.

> do i need to use an int data type for holding unix timestamp or there
> is a data type which was build specialy for that?

I would suggest using the native timestamp type. You can convert back
and forth using various techniques, but you should find that the
examples below give you a good start:

lockhart=# select date_part('epoch',timestamp 'now');
 date_part
-----------
 997993780

lockhart=# select timestamp(integer '997993780');
       timestamp
------------------------
 2001-08-16 20:29:40+00


hth

                      - Thomas

pgsql-general by date:

Previous
From: "Dr. Evil"
Date:
Subject: Re: Storing images in PG?
Next
From: Tom Lane
Date:
Subject: Re: Killing inactive connections