# Date indexes always have a "UTC" timezone
x <- xts(1, Sys.Date())
tzone(x)
str(x)
print(x)
# The default 'tzone' is blank -- your machine's local timezone,
# determined by the 'TZ' environment variable.
x <- xts(1, Sys.time())
tzone(x)
str(x)
# now set 'tzone' to different values
tzone(x) <- "UTC"
str(x)
tzone(x) <- "America/Chicago"
str(x)
y <- timeBasedSeq('2010-01-01/2010-01-03 12:00/H')
y <- xts(seq_along(y), y, tzone = "America/New_York")
# Changing the tzone does not change the internal index values, but it
# does change how the index is printed!
head(y)
head(.index(y))
tzone(y) <- "Europe/London"
head(y) # the index prints with hours, but
head(.index(y)) # the internal index is not changed!
Run the code above in your browser using DataLab