Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

Intl.DurationFormat

Baseline2025
Newly available

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 46min 40s"

仕様書

Specification
Intl.DurationFormat
# durationformat-objects

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp