formatTime()function

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

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

Examples

formatTime("2025-01-01T13:30") // "01:30 PM"