Learn R Programming

verbaliseR (version 0.1)

prettify_date: Render ordinal dates in UK or US style

Description

Render ordinal dates in UK or US style

Usage

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

Value

A string (e.g. "12th September 2022")

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")

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").

Examples

Run this code
prettify_date(Sys.Date(), "UK", "informal")

Run the code above in your browser using DataLab