| as.tzone | R Documentation |
This method allows to determine time index representing the same date and time in a different time zone.
as.tzone(x, tz)
## S3 method for class 'tind'
as.tzone(x, tz)
## S3 method for class 'POSIXct'
as.tzone(x, tz)
## S3 method for class 'POSIXlt'
as.tzone(x, tz)
## S3 method for class 'tinterval'
as.tzone(x, tz)
x |
an object of |
tz |
a character value determining the new time zone.
See |
The underlying time (as measured by number of seconds since the Unix epoch in UTC)
will change so that the date-time components in the new and old time zones
are the same. For tind arguments, if (due to DST time changes or UTC
offset changes) date-time indices do not occur in the new time zone,
NAs are introduced with a warning. For tinterval arguments, the result
is adjusted with a warning, in order not to create open-ended time intervals.
The method is implemented for objects of tind class of type "t"
(date-time), objects of tinterval class of type "t" (time intervals),
as well as base POSIXct and POSIXlt classes.
List of time zones supported by the particular R installation can be obtained
via a call to OlsonNames function.
An object of the same class and length as x with adjusted
underlying date-time representation and time zone set to tz.
tzone method and date_time for construction
od date-time indices from its components.
if (all(c("Europe/Warsaw", "America/New_York") %in% OlsonNames())) {
# check time in one time zone
print(nw <- now(tz = "Europe/Warsaw"))
# the same date-time in a new time zone
print(nw2 <- as.tzone(nw, "America/New_York"))
# note the time difference (equal to the difference of UTC offsets)
# warning on different time zones will be issued
print(suppressWarnings(nw2 - nw))
try(nw2 - nw)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.