Intl

Intl.DurationFormat

Creates an Intl.DurationFormat object that enables locale-sensitive duration formatting

Syntax

JavaScript
new Intl.DurationFormat(locales?, options?)

Parameters

ParameterTypeDescription
localesstring | string[]A BCP 47 language tag or array of tags
optionsobjectOptions: style (long, short, narrow, digital) and per-unit options

Return Value

An Intl.DurationFormat object with a format() method

Examples

Basic Usage
const df = new Intl.DurationFormat('en', { style: 'long' })
console.log(df.format({ hours: 1, minutes: 30 }))
// '1 hour, 30 minutes'
Practical Example
const df = new Intl.DurationFormat('en', { style: 'digital' })
console.log(df.format({ hours: 2, minutes: 5, seconds: 30 }))
// '2:05:30'
Advanced Usage
const df = new Intl.DurationFormat('en', { style: 'short' })
console.log(df.format({ days: 3, hours: 12 }))
// '3 days, 12 hr'

Understanding Intl.DurationFormat

The Intl.DurationFormat method in JavaScript creates an Intl.DurationFormat object that enables locale-sensitive duration formatting. It belongs to the Intl object and is one of the most widely used methods for working with intl values in modern JavaScript and TypeScript applications.

The method signature is new Intl.DurationFormat(locales?, options?). It accepts 2 parameters: locales, options. When called, it returns an intl.durationformat object with a format() method. Understanding when and how to use DurationFormat() helps you write more expressive, readable code.

Common use cases for Intl.DurationFormat include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like intl-relativetimeformat, intl-numberformat, intl-datetimeformat, enabling you to chain operations together for complex data manipulation pipelines.

Supported in Chrome 129+, Firefox 131+, Safari 16.4+. Availability may vary.

Browser Compatibility

Supported in Chrome 129+, Firefox 131+, Safari 16.4+. Availability may vary.

Related Methods

More Intl Methods

Other methods in the Intl object

Related Tools

More Intl Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.