Conveniently get and set the time zone of a date-time.
tz(x) tz(x) <- value
A date-time vector, usually of class
New value of time zone.
A character vector of length 1. An empty string (
your current time zone.
For backward compatibility, the time zone of a date,
character vector is
Time zones are stored in system specific database, so are not guaranteed
to be the same on every system (however, they are usually pretty similar
unless your system is very out of date). You can see a complete list with
See DateTimeClasses for a description of the underlying
x <- y <- ymd_hms("2012-03-26 10:10:00", tz = "UTC") tz(x)#>  "UTC"# Note that setting tz() preserved the clock time, which implies # that the actual instant in time is changing tz(y) <- "Pacific/Auckland" y#>  "2012-03-26 10:10:00 NZDT"x - y#> Time difference of 13 hours# This is the same as force_tz() force_tz(x, "Pacific/Auckland")#>  "2012-03-26 10:10:00 NZDT"# Use with_tz() if you want to change the time zone, leave # the instant in time the same with_tz(x, "Pacific/Auckland")#>  "2012-03-26 23:10:00 NZDT"