Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Standard built-in objects
  5. Intl
  6. Intl.DurationFormat

Intl.DurationFormat

Baseline 2025
Newly available

Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

TheIntl.DurationFormat object enables language-sensitive duration formatting.

Constructor

Intl.DurationFormat()

Creates a newIntl.DurationFormat object.

Static methods

Intl.DurationFormat.supportedLocalesOf()

Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.

Instance properties

These properties are defined onIntl.DurationFormat.prototype and shared by allIntl.DurationFormat instances.

Intl.DurationFormat.prototype.constructor

The constructor function that created the instance object. ForIntl.DurationFormat instances, the initial value is theIntl.DurationFormat constructor.

Intl.DurationFormat.prototype[Symbol.toStringTag]

The initial value of the[Symbol.toStringTag] property is the string"Intl.DurationFormat". This property is used inObject.prototype.toString().

Instance methods

Intl.DurationFormat.prototype.format()

Getter function that formats a duration according to the locale and formatting options of thisDurationFormat object.

Intl.DurationFormat.prototype.formatToParts()

Returns anArray of objects representing the formatted duration in parts.

Intl.DurationFormat.prototype.resolvedOptions()

Returns a new object with properties reflecting the locale and formatting options computed during initialization of the object.

Examples

Using Intl.DurationFormat

The examples below show how to use theIntl.DurationFormat object to format a duration object with various locales and styles.

js
const duration = {  hours: 1,  minutes: 46,  seconds: 40,};// With style set to "long" and locale "fr-FR"new Intl.DurationFormat("fr-FR", { style: "long" }).format(duration);// "1 heure, 46 minutes et 40 secondes"// With style set to "short" and locale "en"new Intl.DurationFormat("en", { style: "short" }).format(duration);// "1 hr, 46 min and 40 sec"// With style set to "narrow" and locale "pt"new Intl.DurationFormat("pt", { style: "narrow" }).format(duration);// "1 h 46 min 40 s"

Specifications

Specification
Intl.DurationFormat
# durationformat-objects

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp