formatDateTime()function

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

Format a datetime in the browser locale (no seconds by default).

Examples

formatDateTime("2025-01-01T13:30") // "1/1/2025, 01:30 PM"