date_format: Formatting: date and date-time

View source: R/date.R

date_formatR Documentation

Formatting: date and date-time

Description

date_format() formats a date (Date) or date-time (POSIXct/POSIXlt) using a format string.

There are separate help pages for formatting dates and date-times:

  • dates (Date)

  • date-times (POSIXct/POSIXlt)

Usage

date_format(x, ...)

Arguments

x

⁠[Date / POSIXct / POSIXlt]⁠

A date or date-time vector.

...

These dots are for future extensions and must be empty.

Value

A character vector of the formatted input.

Examples

# See method specific documentation for more examples

x <- as.Date("2019-01-01")
date_format(x, format = "year: %Y, month: %m, day: %d")

clock documentation built on May 31, 2023, 9:39 p.m.