Intl.DurationFormat

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Das Intl.DurationFormat Objekt ermöglicht sprachsensitive Dauerformatierung.

Konstruktor

Intl.DurationFormat()

Erstellt ein neues Intl.DurationFormat Objekt.

Statische Methoden

Intl.DurationFormat.supportedLocalesOf()

Gibt ein Array zurück, das die von den bereitgestellten Locales enthält, die unterstützt werden, ohne auf die Standardlocale der Laufzeitumgebung zurückzugreifen.

Instanzeigenschaften

Diese Eigenschaften sind auf Intl.DurationFormat.prototype definiert und werden von allen Intl.DurationFormat Instanzen geteilt.

Intl.DurationFormat.prototype.constructor

Die Konstruktorfunktion, die das Instanzobjekt erstellt hat. Für Intl.DurationFormat Instanzen ist der ursprüngliche Wert der Intl.DurationFormat Konstruktor.

Intl.DurationFormat.prototype[Symbol.toStringTag]

Der Anfangswert der [Symbol.toStringTag] Eigenschaft ist der String "Intl.DurationFormat". Diese Eigenschaft wird in Object.prototype.toString() verwendet.

Instanzmethoden

Intl.DurationFormat.prototype.format()

Getter-Funktion, die eine Dauer gemäß der Locale und den Formatierungsoptionen dieses DurationFormat Objekts formatiert.

Intl.DurationFormat.prototype.formatToParts()

Gibt ein Array von Objekten zurück, das die formatierte Dauer in Teilen darstellt.

Intl.DurationFormat.prototype.resolvedOptions()

Gibt ein neues Objekt mit Eigenschaften zurück, die die Locale und die Formatierungsoptionen widerspiegeln, die während der Initialisierung des Objekts berechnet wurden.

Beispiele

Verwendung von Intl.DurationFormat

Die folgenden Beispiele zeigen, wie das Intl.DurationFormat Objekt verwendet wird, um ein Dauerobjekt mit verschiedenen Locales und Stilen zu formatieren.

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);
// "1h 46min 40s"

Spezifikationen

Specification
Intl.DurationFormat
# durationformat-objects

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
DurationFormat
DurationFormat() constructor
format
formatToParts
resolvedOptions
supportedLocalesOf

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support

Siehe auch