我有一个epoch格式的时间戳,如下所示:1551187548876
。如果我使用https://www.epochconverter.com/将其转换为时间戳,我会得到正确的时间。
但是,如果我使用PostgreSQL to_timestamp
将其转换为时间,我会得到以下结果:
select to_timestamp(1551187548876) from my_table;
51125-03-06 14:14:36+00
题
如何将epoch 1551187548876
转换为PostgreSQL中的时间戳?
我假设您拥有的纪元数是自纪元以来的毫秒数,而不是习惯上的秒数。
尝试除以1000:
select to_timestamp(1551187548.876);
to_timestamp
----------------------------
2019-02-26 14:25:48.876+01
(1 row)