Skip to contents

Render ordinal dates in UK or US style

Usage

prettify_date(
  date_to_format = Sys.Date(),
  uk_or_us = c("UK", "US"),
  formal_or_informal = c("informal", "formal")
)

Arguments

date_to_format

The date to use. It must be either be of class Date or a string written as "YYYY-MM-DD" or "YYYY/MM/DD". Can be a vector (e.g. a column in dplyr::mutate()); missing dates stay missing.

uk_or_us

Defaults to "UK", which results in outputs like "12th September 2022"; if "US", the output resembles "September 12th, 2022".

formal_or_informal

Defaults to "informal", so the ordinals are included (e.g. "st", "nd", "rd", "th"). If "formal" is chosen, the ordinals are omitted (e.g. "12 September 2022").

Value

A string (e.g. "12th September 2022"), or a character vector the same length as date_to_format

See also

Other verbaliseR functions: listify(), num_to_text(), pluralise(), restore_capitals()

Examples

prettify_date(Sys.Date(), "UK", "informal")
#> [1] "3rd December 2026"
prettify_date(c("2022-09-01", "2022-09-02"), "US", "formal")
#> [1] "September 1, 2022" "September 2, 2022"