Loading...
const fmt = new Intl.DurationFormat(locale);
fmt.format(5400000);const fmt = new Intl.DurationFormat(locale, {
style: 'short',
});
fmt.format({ hours: 1, minutes: 30 });format() takes a duration object with named units; a plain number of milliseconds throws a TypeError.
format(), which throws a TypeError.format() receives an object like { hours: 1, minutes: 30 }, not a number of milliseconds.Use style: 'digital', which formats hours, minutes and seconds with colons.
No. It formats the units you pass as they are, so convert milliseconds into hours and minutes yourself first.