lubridate (version 1.7.8)

tz: Get/set time zone component of a date-time

Description

Conveniently get and set the time zone of date-time, automatically converting dates to date-times as needed.

Note that tz<- is an alias for force_tz(), which preserves the local time, creating a different instant in time. Use with_tz() if you want keep the instant the same, but change the printed representation.

Usage

tz(x)

tz(x) <- value

Arguments

x

A date-time vector, usually of class POSIXct or POSIXlt.

value

New value of time zone.

Value

A character vector of length 1, giving the time zone of the vector. An empty string ("") represents the current/default timezone.

For backward compatibility, the time zone of a date, NA, or character vector is "UTC".

Valid time zones

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 sytsem is very out of date). You can see a complete list with OlsonNames()

See Also

See DateTimeClasses for a description of the underlying tzone attribute..

Examples

Run this code
# NOT RUN {
x <- ymd("2012-03-26", tz = "UTC")
tz(x)

tz(x) <- "GMT"
x
# }

Run the code above in your browser using DataLab