
Last chance! 50% off unlimited learning
Sale ends in
Format a Datetime vector
formatDatetime(dtv, fmt = "%Y-%m-%dT%H:%M:%E*S%Ez", lcltzstr = "UTC",
tgttzstr = "UTC")formatDouble(secv, nanov, fmt = "%Y-%m-%dT%H:%M:%E*S%Ez",
tgttzstr = "UTC")
A string vector with the requested format of the datetime objects
A Datetime vector object to be formatted
A string with the format, which is based on strftime
with some
extensions; see the CCTZ documentation for details.
The local timezone object for creation the CCTZ timepoint
The target timezone for the desired format
A numeric vector with seconds since the epoch
A numeric vector with nanoseconds since the epoch,
complementing secv
.
Dirk Eddelbuettel
An alternative to format.POSIXct
based on the CCTZ library. The
formatDouble
variant uses two vectors for seconds since the epoch
and fractional nanoseconds, respectively, to provide fuller resolution.
if (FALSE) {
now <- Sys.time()
formatDatetime(now) # current (UTC) time, in full precision RFC3339
formatDatetime(now, tgttzstr="America/New_York") # same but in NY
formatDatetime(now + 0:4) # vectorised
}
Run the code above in your browser using DataLab