Local Time Convert To UTC Time In Hive

前端 未结 5 528
忘掉有多难
忘掉有多难 2020-12-28 20:34

I searched a lot on Internet but couldn\'t find the answer. Here is my question:

I\'m writing some queries in Hive. I have a UTC timestamp and would like to change i

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-28 21:13

    Hey just wanted to add a little here, I'd suggest trying to "automate" the system timezone. So instead of statically

    #STATIC TZ deceleration     
    to_utc_timestamp(from_unixtime(1389802875),'America/Montreal')
    

    Give this a shot

    #DYNAMIC TZ
    select to_utc_timestamp(from_unixtime(1389802875), from_unixtime(unix_timestamp(), "z"));
    

    This just uses the string output format of "from_unixtime" to return the timezone string (lowercase z)

提交回复
热议问题