Summary
The Intl.DateTimeFormat
object is a constructor for objects that enable language sensitive date and time formatting.
Property of Intl |
|
---|---|
ECMAScript Edition | ECMAScript Internationalization API Specification, 1st Edition |
Syntax
new Intl.DateTimeFormat([locales [, options]]) Intl.DateTimeFormat.call(this [, locales [, options]])
Parameters
-
locales
-
A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the
locales
argument, see the Intl page. The following Unicode extension keys are allowed:- nu
- Numbering system. Possible values include: "arab", "arabext", "bali", "beng", "deva", "fullwide", "gujr", "guru", "hanidec", "khmr", "knda", "laoo", "latn", "limb", "mlym", "mong", "mymr", "orya", "tamldec", "telu", "thai", "tibt".
- ca
- Calendar. Possible values include: "buddhist", "chinese", "coptic", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamicc", "iso8601", "japanese", "persian", "roc".
-
options
-
An object with some or all of the following properties:
-
localeMatcher
- The locale matching algorithm to use. Possible values are "lookup" and "best fit"; the default is "best fit". For information about this option, see the Intl page.
-
timeZone
- The time zone to use. The only value implementations must recognize is "UTC"; the default is the runtime's default time zone. Implementations may also recognize the time zone names of the IANA time zone database, such as "Asia/Shanghai", "Asia/Kolkata", "America/New_York".
-
hour12
-
Whether to use 12-hour time (as opposed to 24-hour time). Possible values are
true
andfalse
; the default is locale dependent. -
formatMatcher
- The format matching algorithm to use. Possible values are "basic" and "best fit"; the default is "best fit". See the following paragraphs for information about the use of this property.
The following properties describe the date-time components to use in formatted output, and their desired representations. Implementations are required to support at least the following subsets:
- weekday, year, month, day, hour, minute, second
- weekday, year, month, day
- year, month, day
- year, month
- month, day
- hour, minute, second
- hour, minute
Implementations may support other subsets, and requests will be negotiated against all available subset-representation combinations to find the best match. Two algorithms are available for this negotiation and selected by the formatMatcher property: A fully specified "basic" algorithm and an implementation dependent "best fit" algorithm.
-
weekday
- The representation of the weekday. Possible values are "narrow", "short", "long".
-
era
- The representation of the era. Possible values are "narrow", "short", "long".
-
year
- The representation of the year. Possible values are "numeric", "2-digit".
-
month
- The representation of the month. Possible values are "numeric", "2-digit", "narrow", "short", "long".
-
day
- The representation of the day. Possible values are "numeric", "2-digit".
-
hour
- The representation of the hour. Possible values are "numeric", "2-digit".
-
minute
- The representation of the minute. Possible values are "numeric", "2-digit".
-
second
- The representation of the second. Possible values are "numeric", "2-digit".
-
timeZoneName
- The representation of the time zone name. Possible values are "short", "long".
The default value for each date-time component property is
undefined
, but if all component properties areundefined
, thenyear
,month
, andday
are assumed to be "numeric". -
Description
Properties
{{Js_see_prototype("DateTimeFormat", "Properties")}}
- prototype
- Allows the addition of properties to all objects.
{{jsOverrides("Function", "Properties", "prototype")}}
Methods
{{Js_see_prototype("DateTimeFormat", "Methods")}}
- supportedLocalesOf
- Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.
{{jsOverrides("Function", "Methods")}}
DateTimeFormat
instances
Properties
DateTimeFormat
instances inherit the following properties from their prototype:
Methods
DateTimeFormat
instances inherit the following methods from their prototype: