Examples for 'lubridate::tz'


Get/set time zone component of a date-time

Aliases: tz tz<-

Keywords: chron manip methods utilities

### ** Examples

x <- y <- ymd_hms("2012-03-26 10:10:00", tz = "UTC")
tz(x)
[1] "UTC"
# Note that setting tz() preserved the clock time, which implies
# that the actual instant in time is changing
tz(y) <- "Pacific/Auckland"
y
[1] "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")
[1] "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")
[1] "2012-03-26 23:10:00 NZDT"

[Package lubridate version 1.8.0 Index]