大网数据广告活动
Web 标准与前端开发

Intl.DurationFormat.prototype.resolvedOptions()

· 52CE 我爱测

The **`resolvedOptions()`** method of Intl.DurationFormat instances returns a new object with properties reflecting the options computed during initialization of this `DurationFormat` object.

The resolvedOptions() method of Intl.DurationFormat instances returns a new object with properties reflecting the options computed during initialization of this DurationFormat object.

Syntax

resolvedOptions()

Parameters

None.

Return value

A new object with properties reflecting the options computed during the initialization of this DurationFormat object. The object has the following properties, in the order they are listed:

  • locale
    • : The BCP 47 language tag for the locale actually used, determined by the locale negotiation process. Only the nu Unicode extension key, if requested, may be included in the output.
  • numberingSystem
    • : The value provided for this property in the options argument, or using the Unicode extension key "nu", with default filled in as needed. It is a supported numbering system for this locale. The default is locale dependent.
  • style
    • : The value provided for this property in the options argument, with default filled in as needed. It is either "long", "short", "narrow", or "digital". The default is "short".
  • years, yearsDisplay, months, monthsDisplay, weeks, weeksDisplay, days, daysDisplay, hours, hoursDisplay, minutes, minutesDisplay, seconds, secondsDisplay, milliseconds, millisecondsDisplay, microseconds, microsecondsDisplay, nanoseconds, nanosecondsDisplay
    • : The values provided for these properties in the options argument, with defaults filled in as needed. For the valid values and defaults for each, see the options argument of the constructor.
  • fractionalDigits
    • : The value provided for this property in the options argument. It is only present if specified in options. It is an integer from 0 to 9, inclusive.

Examples

Using the resolvedOptions method

const duration = new Intl.DurationFormat("en");
const usedOptions = duration.resolvedOptions();

usedOptions.locale; // "en"
usedOptions.numberingSystem; // "latn"
usedOptions.years; // "short"
usedOptions.yearsDisplay; // "auto"
usedOptions.style; // "short"

Specifications

Browser compatibility

See also

  • Intl.DurationFormat
  • Intl.supportedValuesOf()
  • Intl

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。