posixt-formatting | R Documentation |
This is a POSIXct method for the date_format()
generic.
date_format()
formats a date-time (POSIXct) using a format
string.
If format
is NULL
, a default format of "%Y-%m-%dT%H:%M:%S%Ez[%Z]"
is
used. This matches the default format that date_time_parse_complete()
parses. Additionally, this format matches the de-facto standard extension to
RFC 3339 for creating completely unambiguous date-times.
## S3 method for class 'POSIXt'
date_format(
x,
...,
format = NULL,
locale = clock_locale(),
abbreviate_zone = FALSE
)
x |
A date-time 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 |
abbreviate_zone |
If If |
A character vector of the formatted input.
x <- date_time_parse(
c("1970-04-26 01:30:00", "1970-04-26 03:30:00"),
zone = "America/New_York"
)
# Default
date_format(x)
# Which is parseable by `date_time_parse_complete()`
date_time_parse_complete(date_format(x))
date_format(x, format = "%B %d, %Y %H:%M:%S")
# By default, `%Z` uses the full zone name, but you can switch to the
# abbreviated name
date_format(x, format = "%z %Z")
date_format(x, format = "%z %Z", abbreviate_zone = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.