0

如何将 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

4

2 回答 2

1

您可以to_timestamp()在 postgresql 中使用。

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

参考链接了解更多详情

对于 8.0:

SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 1541001600 * INTERVAL '1 second';
于 2019-02-12T09:49:51.063 回答
0

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

select '1970-01-01'::timestamp + 1541001600 * interval '1 second'
于 2019-02-12T12:02:51.717 回答