在线文档教程

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"

产品规格

SpecificationStatusComment
ECMAScript Internationalization API 1.0 (ECMA-402)The definition of 'Intl.DateTimeFormat.prototype.resolvedOptions' in that specification.StandardInitial 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

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support241229 (29)111510
computed timeZone351453 (53)No support3010

FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic supportNo support2656.0 (56)No supportNo support10