Intl.DateTimeFormat.prototype.resolvedOptions()
method returns a new object with properties reflecting the locale and date and time formatting options computed during initialization of this
DateTimeFormat
对象。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
dateTimeFormat.resolvedOptions()
A new object with properties reflecting the locale and date and time formatting options computed during the initialization of the given
DateTimeFormat
对象。
The resulting object has the following properties:
locale
locale
.
calendar
E.g. "gregory"
numberingSystem
"ca"
and
"nu"
or filled in as default values.
timeZone
options
argument;
undefined
(representing the runtime's default time zone) if none was provided. Warning: Applications should not rely on
undefined
being returned, as future versions may return a
String
value identifying the runtime’s default time zone instead.
hour12
options
argument or filled in as a default.
weekday
era
year
month
day
hour
minute
second
timeZoneName
options
argument and the available combinations and representations for date-time formatting in the selected locale. Some of these properties may not be present, indicating that the corresponding components will not be represented in formatted output.
resolvedOptions
方法
var germanFakeRegion = new Intl.DateTimeFormat('de-XX', { timeZone: 'UTC' });
var usedOptions = germanFakeRegion.resolvedOptions();
usedOptions.locale; // "de"
usedOptions.calendar; // "gregory"
usedOptions.numberingSystem; // "latn"
usedOptions.timeZone; // "UTC"
usedOptions.month; // "numeric"
| 规范 |
|---|
|
ECMAScript 国际化 API (ECMA-402)
The definition of 'Intl.DateTimeFormat.prototype.resolvedOptions' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
resolvedOptions
|
Chrome 24 | Edge 12 | Firefox 29 | IE 11 | Opera 15 | Safari 10 | WebView Android 4.4 | Chrome Android 25 | Firefox Android 56 | Opera Android 14 | Safari iOS 10 | Samsung Internet Android 1.5 |
nodejs
0.12
|
computed
timeZone
|
Chrome 35 | Edge 14 | Firefox 53 | IE No | Opera 30 | Safari 10 | WebView Android ≤37 | Chrome Android 35 | Firefox Android 56 | Opera Android 22 | Safari iOS 10 | Samsung Internet Android 3.0 | nodejs 8.10.0 |
完整支持
不支持
见实现注意事项。
Intl
Collator
DateTimeFormat
ListFormat
NumberFormat
PluralRules
RelativeTimeFormat
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()