Date/time component options
WARNING
These options are incompatible with presets and cannot be used simultaneously.
weekday
The representation of the weekday. Possible values are:
"long"
- E.g., Thursday"short"
- E.g., Thu"narrow"
- E.g., T
NOTE
Some locales may use the same narrow style for multiple weekdays (e.g., Tuesday and Thursday both use T).
Examples:
era
The representation of the era. Possible values are "long"
, "short"
, and "narrow"
.
Examples:
year
The year can be displayed as "numeric"
(e.g., 2023) or "2-digit"
(e.g., 23).
Examples:
month
The representation of the month. Possible values are:
"numeric"
- E.g., 3"2-digit"
- E.g., 03"long"
- E.g., March"short"
- E.g., Mar"narrow"
- E.g., M.
NOTE
Two months may have the same narrow style for some locales (e.g., May's narrow style is also M).
Examples:
day
The day can be displayed as "numeric"
(e.g., 1) or "2-digit"
(e.g., 01).
Examples:
dayPeriod
The formatting style for day periods such as "am", "noon", or "in the morning". Possible values are "narrow"
, "short"
, and "long"
.
NOTE
This option only applies when using a 12-hour clock (hourCycle
: "h12"
or "h11"
) and may not vary across widths in some locales.
Examples:
Formatter options used in this example
{
hourCycle: 'h12';
}
hour
The hour can be displayed as "numeric"
(e.g., 1) or "2-digit"
(e.g., 01).
Examples:
minute
The minute can be displayed as "numeric"
(e.g., 1) or "2-digit"
(e.g., 01).
Examples:
second
The second can be displayed as "numeric"
(e.g., 1) or "2-digit"
(e.g., 01).
Examples:
fractionalSecondDigits
The number of fractional second digits to display. Valid values are 1
, 2
, or 3
. Extra digits are truncated.
Examples:
formatMatcher
The format matching algorithm to use. Possible values are "basic"
and "best fit"
. The default is "best fit"
. "Basic"
follows the specification, while "best fit"
is implementation-defined.
"Attributions and copyright licensing" by Mozilla Contributors, licensed under CC-BY-SA 4.0.