Was ist Intl.DurationFormat Generator?
Intl.DurationFormat is a built-in browser API that formats time durations according to locale conventions. Given a duration object with fields like hours, minutes, and seconds, it produces human-readable strings such as "1 hour, 30 minutes" (English long), "1 Std 30 Min." (German short), or "1:30:00" (digital). It supports four styles: long, short, narrow, and digital. Available in Chrome 104+ and part of Baseline 2025.
Kurze Antwort
Generate code using Intl.DurationFormat to display time durations in a locale-aware format. Choose between long, short, narrow, and digital styles. Supports English, German, French, Spanish, Japanese, and Dutch. Drop moment-duration-format and use the native API instead.
Einschränkungen
- Intl.DurationFormat is not available in Safari as of mid-2026. Use a polyfill or fallback library for Safari users, or implement a simple manual formatter for basic cases.
- The API does not aggregate units automatically — { hours: 1, minutes: 90 } formats as '1 hour, 90 minutes', not '2 hours, 30 minutes'. Normalize your duration before formatting if you want automatic unit conversion.
- Each locale determines its own formatting rules and word choices. The digital style produces consistent numeric output, but long/short/narrow styles may vary in ways that affect layout width. Test across your target locales to avoid text overflow.
So nutzt du dieses Tool
- Create a duration object with the time components you want to format: { hours: 1, minutes: 30, seconds: 0 }.
- Construct a new Intl.DurationFormat instance with your chosen locale and optional style configuration.
- Call format(duration) on the instance to get the localized string, or call formatToParts(duration) for an array of formatted components.
- Experiment with different locales and styles in the tool to see how duration strings change across languages.
Wofür du es nutzen kannst
- Display video length or podcast duration in a localized media player interface.
- Show estimated reading time or processing time in a user's preferred language format.
- Format server-side durations (API response times, job runtimes) for internationalized admin dashboards.