【问题标题】:postgresql numeric to timestamp conversion timezone issuepostgresql 数字到时间戳转换时区问题
【发布时间】:2014-10-22 18:16:36
【问题描述】:

我正在尝试在 postgresql 中将数字转换为时间戳。但是,它总是在 EST 时区转换它。在运行查询之前,我尝试以下操作。

set time zone 'UTC+10';

select to_timestamp(r.date/1000) as current_email_timestamp
FROM email;

但是,时间戳似乎总是在美国时区。电子邮件大多是在工作时间发送的,但是当我使用上述查询将数字改回时间戳时,它会在夜间显示所有电子邮件

可能是数字中的时间戳存储在美国时区,或者是从数字转换回时间戳时,它没有正确覆盖时区。

谁能告诉我如何解决这个问题

问候 阿里夫

【问题讨论】:

  • 你能告诉我们输入的数字是什么样的吗?

标签: postgresql


【解决方案1】:

您可以使用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。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-01
    • 1970-01-01
    • 2011-05-21
    • 2014-02-12
    相关资源
    最近更新 更多