Converts a Date object to character data
dateFormat(date, format = NULL, optimize.dups=TRUE)
A vector of dates. Can be character data or some date
object -- anything that can be handled by dateParse()
A specification of the format. The default will print as "YYYY-MM-DD" under both Windows and Linux.
If TRUE
, internally optimize by not performing
the same computation multiple times for duplicates. This does
not change the return value.
The formatted dates as a vector of character data.
Unfortunately, 'format.POSIXct' does not have the same behavior on Linux and Windows. Here are a few for the difference found in 2008:
Windows version does not recognize "%y" format.
Windows version does not recognize width arguments like "%02d".
Windows and Linux does not agree on the meaning of "%Y". Under Windows it means "%04Y"; under Linux it prints with minimal width.
This function tries to provide identical behavior under Linux and
Windows and Mac.
This function formats any kind of data objects to character
strings with the default format "%04Y-%02m-%02d" under
both Linux and Windows. It does this by choosing a system-specific
default format and then calling format()
.
Additional format specifications are also provided:
'%Q' for quarter, as 'Q1', etc (the value returned by quarters()
'%C' for century, always 2 digits (e.g., '20' for 2013)
# NOT RUN {
dateFormat(as.Date('2001-02-13'), '%Y.%02m.%02d')
# }
Run the code above in your browser using DataLab