s <- rast(system.file("ex/logo.tif", package="terra"))
# Date"
d <- as.Date("2001-05-04") + 0:2
time(s) <- d
time(s)
# POSIX (date/time with a resolution of seconds)
time(s) <- as.POSIXlt(d)
time(s)
# with time zone
time(s) <- as.POSIXlt(Sys.time(), "America/New_York") + 0:2
time(s)
timeInfo(s)
# years
time(s, tstep="years") <- 2000 + 0:2
s
time(s, tstep="months") <- 1:3
s
Run the code above in your browser using DataLab