Convert POSIXt Object to UTC Time Zone
toUTC(x)
x | object of class POSIXt (either POSIXct or POSIXlt) |
---|
POSIXt object in UTC timezone (hopefully!)
# Create a timestamp in the time zone that is set on the local machine time <- as.POSIXct("2017-11-01 01:16") # Convert time zone to UTC time_utc <- toUTC(time) # The new time zone "UTC" is set in the attribute "tz" attr(time_utc, "tz")#> [1] "UTC"# The times mean the same, just expressed in another time zone! time_utc == time#> [1] TRUE