Formats a duration in milliseconds to a padded time string.

Type signature

(duration: number, showSeconds?: boolean) => string

Examples

formatDuration(26100000);
// ⇒ 07:15
Try in REPL
formatDuration(26136000, true);
// ⇒ 07:15:36
Try in REPL

Questions

  • How to render a formatted duration?

TypeScript sourceJavaScript source