Skip to content

formatDate()

function formatDate(
value,
pattern,
locale?,
calendar?
): string;

Formats a date with a pattern. Supported tokens: yyyy yy MMMM MMM MM M dd d EEEE EEE HH H hh h mm m ss s SSS a. Text in single quotes is literal; ‘’ is a literal quote.

Month and weekday names follow locale. Numbers use the locale’s digits (Persian digits for fa-IR). calendar selects the calendar of the year, month and day tokens; the default is Gregorian, whatever the locale’s own default calendar is.

Parameter Type Default value
value Date undefined
pattern string undefined
locale string DEFAULT_LOCALE
calendar? string undefined

string