change_tz(Sys.time(), tz = "NZ")
change_tz(Sys.time(), tz = "US/Hawaii")
# from "POSIXct" time:
tc <- as.POSIXct("2020-07-01 12:00:00", tz = "UTC")
change_tz(tc, "Australia/Melbourne")
change_tz(tc, "Europe/Berlin")
change_tz(tc, "US/Pacific")
# from "POSIXlt" time:
tl <- as.POSIXlt("2020-07-01 12:00:00", tz = "UTC")
change_tz(tl, "Australia/Melbourne")
change_tz(tl, "Europe/Berlin")
change_tz(tl, "US/Pacific")
# from "Date":
dt <- as.Date("2020-12-31")
change_tz(dt, "NZ")
change_tz(dt, "US/Hawaii") # Note different date!
# with a vector of "POSIXct" times:
t2 <- as.POSIXct("2020-12-31 23:59:55", tz = "US/Pacific")
tv <- c(tc, t2)
tv # Note: Both times in tz of tc
change_tz(tv, "US/Pacific")
Run the code above in your browser using DataLab