formatDate()function

formatDate(date: PossibleDate, options?: DateFormatOptions, caller: AnyCaller = formatDate): string
ParamType
datePossibleDate
Date to format. required
optionsDateFormatOptions
Formatting options passed through to Date.toLocaleDateString.
    .localeIntl.Locale
Override the locale for formatting (defaults to detected locale). readonly
callerAnyCaller
Function to attribute a thrown error to (defaults to formatDate itself). Defaults to formatDate
Return
string
Locale-formatted date string.
Throws
RequiredError
If date cannot be converted to a valid date.

Format a date in the browser locale.

Examples

formatDate("2025-01-01") // "1/1/2025"