如何在psql中转换unix_timestamp整数?

问题描述 投票:0回答:2

如何将unix_timestamp整数转换为可读文本中的时间。 如:

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

1541001600应转换为Thu Nov 1 00:00:00 CST 2018

PostgreSQL 8.0.2

sql postgresql unix-timestamp postgresql-8.0
2个回答
0
投票

你可以在postgresql中使用to_timestamp()

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

有关详细信息,请参阅Link

对于8.0:

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

0
投票

你应该真的升级你的Postgres!但我认为这会奏效:

select '1970-01-01'::timestamp + 1541001600 * interval '1 second'
© www.soinside.com 2019 - 2024. All rights reserved.