【问题标题】:Postgresql - How to fix invalid hour in timestamp?Postgresql - 如何修复时间戳中的无效小时?
【发布时间】:2020-04-06 19:45:49
【问题描述】:

我有一个表,其中有一个名为revtstmp 的字段,类型为bigint

我尝试使用以下代码格式化此字段:

  select
     to_char(to_timestamp(revtstmp/1000) AT TIME ZONE 'GMT', 'Day DD Month YYYY HH:mm:ss')
  from
     my_table

对于1571931942630 的值,我希望看到Thursday 24 October 2019 15:45:42
但是,我看到Thursday 24 October 2019 03:10:42

我错过了什么?

【问题讨论】:

    标签: postgresql timestamp


    【解决方案1】:

    在几个小时内使用适当的模式,请参阅Template Patterns for Date/Time Formatting.

     select
         to_char(to_timestamp(revtstmp/1000) AT TIME ZONE 'GMT', 'Day DD Month YYYY HH24:MI:SS')
      from
         my_table
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-24
      • 1970-01-01
      • 1970-01-01
      • 2014-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多