JavaScript参考手册
Intl
Intl.dateTimeFormat.resolvedOptions
该Intl.DateTimeFormat.prototype.resolvedOptions()
方法返回一个新对象,其属性反映在此DateTimeFormat
对象的初始化期间计算的语言环境和日期和时间格式选项。
句法
dateTimeFormat.resolvedOptions()
返回值
一个新对象, 它具有反映给定 DateTimeFormat
对象初始化期间计算的区域设置和日期和时间格式选项的属性。
描述
结果对象具有以下属性:
locale
实际使用的语言环境的BCP 47语言标记。如果在导致该语言环境的输入BCP 47语言标签中请求了任何Unicode扩展值,那么请求并支持该语言环境的键值对将包含在中locale
。
calendarnumberingSystem
使用Unicode扩展键"ca"
和"nu"
或请求的值被填充为默认值。timeZone
在options
参数中为此属性提供的值; undefined
(代表运行时的默认时区),如果没有提供。警告:应用程序不应该依赖undefined
返回,因为未来的版本可能会返回一个String
标识运行时默认时区的值。hour12
在options
参数中为此属性提供的值或填充为默认值。
weekdayerayearmonthdayhourminutesecondtimeZoneNameoptions
参数中相应属性之间的格式匹配以及所选语言环境中日期时间格式的可用组合和表示形式所产生的值。其中一些属性可能不存在,表示相应的组件不会以格式化输出表示。
示例
使用该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 |
Intl相关

JavaScript 是一种高级编程语言,通过解释执行,是一门动态类型,面向对象(基于原型)的解释型语言。它已经由ECMA(欧洲电脑制造商协会)通过 ECMAScript 实现语言的标准化。它被世界上的绝大多数网站所使用,也被世界主流浏览器( Chrome、IE、FireFox、Safari、Opera )支持。JavaScript 是一门基于原型、函数先行的语言,是一门多范式的语言,它支持面向对象编程,命令式编程,以及函数式编程。它提供语法来操控文本、数组、日期以及正则表达式等,不支持 I/O,比如网络