Skip site navigation (1) Skip section navigation (2)

converting seconds since epoch to time string

From: Bill Morrow <wmorrow(at)home(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: converting seconds since epoch to time string
Date: 2000-11-14 23:04:20
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
I have an integer column which holds a time represented
as the number of seconds since 1970/01/01 00:00 UTC. I want to
view this table with the time converted to an understandable text string.

I've experimented with things like

select to_char('epoch'::datetime + '973660200 seconds'::interval, 'dd/mm/yyyy hh:mi');
 07/11/2000 10:10 

but can't see anyway to use the time column in my table, instead of a hardcode
number of seconds.

In Sybase, you can use the dateadd() function to do this:

select dateadd( seconds, time, '1/1/70') from tablename



pgsql-novice by date

Next:From: Tom LaneDate: 2000-11-14 23:23:53
Subject: Re: converting seconds since epoch to time string
Previous:From: Stephan SzaboDate: 2000-11-14 17:25:20
Subject: Re: smallint to bigint

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group