Firefox Tomorrow

javascript class

Intl.DurationFormat

View on MDN ↗

The Intl.DurationFormat object enables language-sensitive duration formatting.

Constructor

Static methods

Instance properties

These properties are defined on Intl.DurationFormat.prototype and shared by all Intl.DurationFormat instances.

Instance methods

Examples

Using Intl.DurationFormat

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

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

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also