Re: How to typecast an integer into a timestamp?

From: Bruno Boettcher <bboett(at)bboett(dot)adlp(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to typecast an integer into a timestamp?
Date: 2012-01-28 09:43:43
Message-ID: 20120128094343.GH7071@bboett.adlp.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jan 27, 2012 at 08:17:37AM -0800, Adrian Klaver wrote:
> Did some digging. php-mktime returns the Unix epoch (seconds since January 1
> 1970 00:00:00 GMT)
indeed, didn't get it that postgres timestamp wasn't the same....

> Postgres has a function(to_timestamp) that will convert that to a timestamp:
>
> http://www.postgresql.org/docs/9.0/interactive/functions-formatting.html
>
> to_timestamp(double precision) timestamp with time zone convert Unix
> epoch to time stamp to_timestamp(1284352323)
>
> So something like the below in your query should work:
>
> to_timestamp(int_returned_from_php)
very neat that does it!
thanks a lot everybody!

ciao
Bruno

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-01-28 15:15:19 Re: How to typecast an integer into a timestamp?
Previous Message hubert depesz lubaczewski 2012-01-28 09:30:11 Re: pg_dump -s dumps data?!