【问题标题】:HIVE from.unixtime(...) with Time ZoneHIVE from.unixtime(...) with Time Zone
【发布时间】:2021-12-14 04:23:35
【问题描述】:

我在具有 GMT+8 时区的机器上设置了我的 Hive。因此,from_unixtime(946656000) 返回 2000-01-01 00:00:00 而不是 1999-12-31 16:30:00。根据手册,此函数使用当前系统时区返回日期字符串。我该怎么做才能获得带有 UTC 时区的日期字符串,即1999-12-31 16:30:00

【问题讨论】:

    标签: hive


    【解决方案1】:

    您可以使用to_utc_timestamp(T timestamp, STRING timezone)。 这是一个将 IST 中的时间戳转换为 UTC 的示例。

    select TO_UTC_TIMESTAMP(from_unixtime(946656000),'IST') c
    

    【讨论】:

      猜你喜欢
      • 2012-04-04
      • 2011-03-14
      • 2023-01-10
      • 2020-09-20
      • 1970-01-01
      • 2018-10-20
      • 1970-01-01
      • 2021-08-24
      • 1970-01-01
      相关资源
      最近更新 更多