setTZ: Set Time Zone

View source: R/setTZ.R

setTZR Documentation

Set Time Zone

Description

Set the time-zone information for dates and times.

Usage

setTZ(x, TZ, force.stz = FALSE)

Arguments

x

the date-time data, generally class "POSIXct."

TZ

time-zone code or time-zone name, see Details.

force.stz

force standard time specified in TZ. Useful for Arizona times, where daylight savings is not used, or in other cases where all times are recorded as standard time. Also useful when the dates and times are recorded over the transition from daylight savings time to standard time. Valid only in the United States. Used only when retrieving data from a single time zone.

Details

The time-zone information should be a standard name like those described in http://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones. For the convenience of users in the United States, correct conversion is provided for the time-zone codes of EST, EDT, CST, CDT, MST, MDT, PST, PDT, AKST, AST, AKDT, ADT, HAST, and HST. However, time data in States like Arizona, where savings time is never used, would use time-zone information specified like " America/Phoenix" to avoid the possibility of setting savings time when it is not appropriate.

Value

Data like x, but with times adjusted by the time-zone information.

Note

The time-zone information is a characterisitic of the data and not of each individual value. If the data in x come from different time zones, then a time zone is selected from the data and used as the baseā€”the dates in x are correctly converted to the selected time zone and a warning is issued.

See Also

as.POSIXct

Examples


TestDts <- as.POSIXct(c("2010-05-28 09:50:00", "2010-11-29 15:20:00"))
setTZ(TestDts, c("PDT", "PST"))
# Try setting to different time zones
setTZ(TestDts, c("PDT", "CST"))

USGS-R/smwrBase documentation built on Oct. 18, 2022, 9:55 a.m.