This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

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.

Intl.DurationFormat 은 언어에 맞는 지속 시간 서식을 지원하는 객체입니다.

생성자

Intl.DurationFormat()

새로운 Intl.DurationFormat 객체를 생성합니다.

정적 메서드

Intl.DurationFormat.supportedLocalesOf()

주어진 로케일 목록 중, 런타임이 지원하는 항목을 배열로 반환합니다.

인스턴스 속성

아래의 속성은 Intl.DurationFormat.prototype에서 정의되어 있으며 모든 Intl.DurationFormat 인스턴스에서 공유됩니다.

Intl.DurationFormat.prototype.constructor

인스턴스 객체를 만든 생성자 함수입니다. Intl.DurationFormat 인스턴스의 경우 초기 값은 Intl.DurationFormat 생성자입니다.

Intl.DurationFormat.prototype[Symbol.toStringTag]

[Symbol.toStringTag] 속성의 초기 값은 문자열 "Intl.DurationFormat"입니다. 이 속성은 Object.prototype.toString()에서 사용됩니다.

인스턴스 메서드

Intl.DurationFormat.prototype.format()

DurationFormat 객체의 로케일과 서식 옵션에 맞춰 지속 시간을 서식화해 반환합니다.

Intl.DurationFormat.prototype.formatToParts()

서식화된 지속 시간을 각 부분 단위로 분해하여 표현하는 객체의 Array를 반환합니다.

Intl.DurationFormat.prototype.resolvedOptions()

객체 초기화 중에 계산된 로케일과 서식 옵션을 반영한 속성이 있는 새 객체를 반환합니다.

예제

Intl.DurationFormat 사용하기

아래의 예제들은 다양한 로케일과 서식 옵션을 사용하여 Intl.DurationFormat 객체로 지속 시간 객체를 형식화하는 방법을 보여줍니다.

js
const duration = {
  hours: 1,
  minutes: 46,
  seconds: 40,
};

// 서식 옵션을 "long"으로 설정하고, 로케일을 "fr-FR"로 설정
new Intl.DurationFormat("fr-FR", { style: "long" }).format(duration);
// "1 heure, 46 minutes et 40 secondes"

// 서식 옵션을 "short"으로 설정하고, 로케일을 "en"로 설정
new Intl.DurationFormat("en", { style: "short" }).format(duration);
// "1 hr, 46 min and 40 sec"

// 서식 옵션을 "narrow"으로 설정하고, 로케일을 "pt"로 설정
new Intl.DurationFormat("pt", { style: "narrow" }).format(duration);
// "1h 46 min 40s"

명세서

Specification
Intl.DurationFormat
# durationformat-objects

브라우저 호환성

같이 보기