Fetch
Fetch

Reputation: 17

Why is as.POSIXct outputting BST instead of 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"

same output with GMT instead of UTC set as the timezone

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"

for reference I'm doing this in Rstudio

Upvotes: 0

Views: 197

Answers (1)

stlba
stlba

Reputation: 767

The option for timezone is "tz" not "tx". This works as expected:

> 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"

Upvotes: 1

Related Questions