[R] Force conversion of (POSIXct) time zone with base R
Iago Giné Vázquez
|@go@g|ne @end|ng |rom @jd@e@
Thu Aug 22 10:59:46 CEST 2024
Hi,
How should POSIXct time zone be changed without modifying the specified time (so fix the time zone). I tried
> now <- Sys.time()
> now
[1] "2024-08-22 10:56:24 CEST"
> as.POSIXct(now, tz = "UTC")
[1] "2024-08-22 08:56:24 UTC"
> as.POSIXct(now, origin = as.POSIXct("1970-01-01", tz = "UTC"), tz = "UTC")
[1] "2024-08-22 08:56:24 UTC"
> format(now, tz = "UTC")
[1] "2024-08-22 08:56:24"
But I want
"2024-08-22 10:56:24 UTC"
Thanks!
Best regards,
Iago
[[alternative HTML version deleted]]
More information about the R-help
mailing list