date-formatting | R Documentation |
This is a Date method for the date_format()
generic.
date_format()
formats a date (Date) using a format
string.
If format
is NULL
, a default format of "%Y-%m-%d"
is used.
## S3 method for class 'Date'
date_format(x, ..., format = NULL, locale = clock_locale())
x |
A date vector. |
... |
These dots are for future extensions and must be empty. |
format |
If Otherwise, a format string which is a combination of: Year
Month
Day
Day of the week
ISO 8601 week-based year
Week of the year
Day of the year
Date
Time of day
Time zone
Miscellaneous
|
locale |
A locale object created from |
Because a Date is considered to be a naive type in clock, meaning that
it currently has no implied time zone, using the %z
or %Z
format commands
is not allowed and will result in NA
.
A character vector of the formatted input.
x <- as.Date("2019-01-01")
# Default
date_format(x)
date_format(x, format = "year: %Y, month: %m, day: %d")
# With different locales
date_format(x, format = "%A, %B %d, %Y")
date_format(x, format = "%A, %B %d, %Y", locale = clock_locale("fr"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.