0

How to convert a unix_timestamp integer to time in readable text.
Such as:

timestamp|integer|not null default 0
select timestamp from table limit 1; 
1541001600  

1541001600 should be converted to Thu Nov 1 00:00:00 CST 2018

PostgreSQL 8.0.2

Cow
  • 99
  • 7
  • 1
    Are you really still using Postgres 8.0? That has been unsupported for ages. What does `select version();` show you? –  Feb 12 '19 at 09:50

2 Answers2

1

You can use to_timestamp() in postgresql.

select to_timestamp(1541001600) AT TIME ZONE 'CST';

Refer Link for more details

For 8.0:

SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 1541001600 * INTERVAL '1 second';
0

You should really upgrade your Postgres! But I think this will work:

select '1970-01-01'::timestamp + 1541001600 * interval '1 second'
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786