Intl.dateTimeFormat.resolvedOptions
Intl.dateTimeFormat.resolvedOptions
该Intl.DateTimeFormat.prototype.resolvedOptions()
方法返回一个新对象,其属性反映在此DateTimeFormat
对象的初始化期间计算的语言环境和日期和时间格式选项。
句法
dateTimeFormat.resolvedOptions()
返回值
一个新对象, 它具有反映给定 DateTimeFormat
对象初始化期间计算的区域设置和日期和时间格式选项的属性。
描述
结果对象具有以下属性:
locale
实际使用的语言环境的BCP 47语言标记。如果在导致该语言环境的输入BCP 47语言标签中请求了任何Unicode扩展值,那么请求并支持该语言环境的键值对将包含在中locale
。
示例
使用该resolvedOptions方法
var germanFakeRegion = new Intl.DateTimeFormat('de-XX', { timeZone: 'UTC' }
var usedOptions = germanFakeRegion.resolvedOptions(
usedOptions.locale; // "de"
usedOptions.calendar; // "gregory"
usedOption.numberingSystem; // "latn"
usedOptions.timeZone; // "UTC"
usedOptions.month; // "numeric"
产品规格
Specification | Status | Comment |
---|---|---|
ECMAScript Internationalization API 1.0 (ECMA-402)The definition of 'Intl.DateTimeFormat.prototype.resolvedOptions' in that specification. | Standard | Initial definition. |
ECMAScript Internationalization API 2.0 (ECMA-402)The definition of 'Intl.DateTimeFormat.prototype.resolvedOptions' in that specification. | Standard | |
ECMAScript Internationalization API 4.0 (ECMA-402)The definition of 'Intl.DateTimeFormat.prototype.resolvedOptions' in that specification. | Draft | |
浏览器兼容性
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 24 | 12 | 29 (29) | 11 | 15 | 10 |
computed timeZone | 35 | 14 | 53 (53) | No support | 30 | 10 |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | No support | 26 | 56.0 (56) | No support | No support | 10 |