配置单元将pht时间转换为utc

t8e9dugd  于 2021-06-24  发布在  Hive
关注(0)|答案(3)|浏览(653)
select to_utc_timestamp(current_timestamp(),'IST');

正在转换为 utcist . 但是,

select to_utc_timestamp(current_timestamp(),'PHT');
``` `PHT` 时间不是转换,它只是返回当前的时间戳 `utc` . 

select current_timestamp(),to_utc_timestamp(current_timestamp(),'PHT');

| 2019-07-10 07:52:29.795 | 2019-07-10 07:52:29.795 |

返回 `utc` 只是。
vdzxcuhz

vdzxcuhz1#

您需要指定国家的大陆/首都:

select to_utc_timestamp(current_timestamp(),'Asia/Manila');
4ktjp1zp

4ktjp1zp2#

'PHT' 无法识别timezine,因为java.time.zoneid不包含此类区域,它包含 IST 不过。使用gmt偏移量表示法如下:

hive> select current_timestamp(),to_utc_timestamp(current_timestamp(),'GMT+8:00');
OK
2019-07-10 23:21:24.743 2019-07-10 15:21:24.743
Time taken: 0.096 seconds, Fetched: 1 row(s)

我不完全确定是不是 GMT+8:00 在菲律宾还是应该 GMT-8:00 ,你应该更清楚, to_utc_timestamp() 如果您指定正确的gmt偏移量,将正常工作。在马尼拉没有夏令时,因此这种方法应该很好的工作。
亚洲/马尼拉也很好,正如@f.lazarescu提到的,最好使用时区标识符而不是gmt偏移量,因为如果适用,夏令时将被计算在内:

select current_timestamp(),to_utc_timestamp(current_timestamp(),'Asia/Manila');
OK
2019-07-11 23:09:47.257 2019-07-11 15:09:47.257
Time taken: 4.029 seconds, Fetched: 1 row(s)

看看这篇相当有用的文章:小心sqoop、hive、impala和spark的时区

b4lqfgs4

b4lqfgs43#

不要使用时区缩写作为标识符。 IST 可以是 India Standard Time , Israel Standard Time 或者 Ireland Standard Time . (还有很多其他的模棱两可的地方。)
如果 IST 你是说印度,那就用吧 'Asia/Kolkata' 如果 IST 你是说以色列,那就用吧 'Asia/Jerusalem' 如果 IST 你是说艾兰特,那就用吧 'Europe/Dublin' 而不是 PHT ,使用 'Asia/Manila' 对菲律宾来说
有关完整的列表,请参阅wikipedia上的tz数据库时区列表。

相关问题