将纪元转换为时间戳时获取不正确的日期

Ant*_*ony 1 sql postgresql epoch sql-timestamp

我有一个纪元格式的时间戳,如下所示:1551187548876如果我使用https://www.epochconverter.com/将其转换为时间戳,我会得到正确的时间。

但是,如果我使用 PostgreSQL 将其转换为时间to_timestamp,我会得到以下结果:

select to_timestamp(1551187548876) from my_table;

51125-03-06 14:14:36+00
Run Code Online (Sandbox Code Playgroud)

问题

如何1551187548876在 PostgreSQL 中将纪元转换为时间戳?

Lau*_*lbe 5

我假设您拥有的纪元号是自纪元以来的毫秒数而不是按照惯例的秒数。

尝试除以 1000:

select to_timestamp(1551187548.876);

        to_timestamp        
----------------------------
 2019-02-26 14:25:48.876+01
(1 row)
Run Code Online (Sandbox Code Playgroud)