我正在尝试在postgresql中将数字转换为时间戳。然而,它总是在EST时区进行转换。在运行查询之前,我尝试以下操作。
set time zone 'UTC+10';
select to_timestamp(r.date/1000) as current_email_timestamp
FROM email;
然而,时间戳似乎总是在美国时区。电子邮件大多在工作时间发送,但当我用上面的查询将数字改回时间戳时,它会显示夜间的所有电子邮件
可能是数字形式的时间戳存储在美国时区,也可能是从数字转换回时间戳时没有正确覆盖时区。
有人能告诉我如何修理吗
问候Arif
您可以使用at time zone
修饰符:
select to_timestamp(1411738200),
to_timestamp(1411738200) at time zone 'America/Chicago',
to_timestamp(1411738200) at time zone 'UTC+10'
您的postgres安装可能默认为EST。