| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat | [Back] [Original] |
Get to know MDN better
Dieser Inhalt wurde automatisch aus dem Englischen bersetzt, und kann Fehler enthalten. Erfahre mehr ber dieses Experiment.
Seit Mrz 2025 funktioniert diese Funktion auf aktuellen Gerten und in aktuellen Browserversionen. Auf lteren Gerten oder in lteren Browsern funktioniert sie mglicherweise nicht.
Das Intl.DurationFormat-Objekt ermglicht sprachsensitives Formatieren von Zeitdauern.
Intl.DurationFormat()Erstellt ein neues Intl.DurationFormat-Objekt.
Intl.DurationFormat.supportedLocalesOf()Gibt ein Array zurck, das die der angegebenen Sprachcodes enthlt, die untersttzt werden, ohne auf die Standard-Spracheinstellung der Laufzeitumgebung zurckfallen zu mssen.
Diese Eigenschaften sind auf Intl.DurationFormat.prototype definiert und werden von allen Intl.DurationFormat Instanzen geteilt.
Intl.DurationFormat.prototype.constructorDie Konstruktorfunktion, die das Instanzobjekt erstellt hat. Fr Intl.DurationFormat Instanzen ist der Anfangswert 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.
Intl.DurationFormat.prototype.format()Getter-Funktion, die eine Dauer entsprechend der Sprach- und Formatierungsoptionen dieses DurationFormat-Objekts formatiert.
Intl.DurationFormat.prototype.formatToParts()Gibt ein Array von Objekten zurck, die die formatierte Dauer in Teilen reprsentieren.
Intl.DurationFormat.prototype.resolvedOptions()Gibt ein neues Objekt mit Eigenschaften zurck, die die Spracheinstellungen und Formatierungsoptionen widerspiegeln, die whrend der Initialisierung des Objekts berechnet wurden.
Die folgenden Beispiele zeigen, wie das Intl.DurationFormat-Objekt verwendet wird, um ein Zeitdauer-Objekt mit verschiedenen Sprachen und Stilen zu formatieren.
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"
| Spezifikation |
|---|
| Intl.DurationFormat # durationformat-objects |
Intl.DurationFormatObject/FunctionIntlIntl.CollatorIntl.DateTimeFormatIntl.DisplayNamesIntl.ListFormatIntl.LocaleIntl.NumberFormatIntl.PluralRulesIntl.RelativeTimeFormatIntl.SegmenterDer Bauplan fr ein besseres Internet.
Teile dieses Inhalts sind 19982026 von einzelnen mozilla.org-Mitwirkenden. Inhalte sind verfgbar unter einer Creative-Commons-Lizenz.
| Web Proxy Viewer | New URL | Original Page |