为什么as.POSIXct输出BST而不是UTC?

问题描述

as.POSIXct("Tue Aug 18 2020 08:45:02 GMT+0000 (Coordinated Universal Time)",tx="UTC",format = "%a %b %d %Y %H:%M:%OS")
[1] "2020-07-13 08:24:03 BST"

与GMT相同的输出,而不是将UTC设置为时区

as.POSIXct("Tue Aug 18 2020 08:45:02 GMT+0000 (Coordinated Universal Time)",tx="GMT",format = "%a %b %d %Y %H:%M:%OS")
[1] "2020-07-13 08:24:03 BST"

作为参考,我正在Rstudio中这样做

解决方法

时区的选项是“ tz”而不是“ tx”。可以按预期工作:

> as.POSIXct("Tue Aug 18 2020 08:45:02 GMT+0000 (Coordinated Universal Time)",tz="UTC",format = "%a %b %d %Y %H:%M:%OS")
[1] "2020-08-18 08:45:02 UTC"