Works with
•JSR Score58%•It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun




Published2 years ago (0.215.0)
Format milliseconds to time duration.
import { format } from "@std/fmt/duration"; // "00:00:01:39:674:000:000" format(99674, { style: "digital" }); // "0d 0h 1m 39s 674ms 0µs 0ns" format(99674); // "1m 39s 674ms" format(99674, { ignoreZero: true }); // "1 minutes, 39 seconds, 674 milliseconds" format(99674, { style: "full", ignoreZero: true });
Functions
f
format(): string
ms: number,
options?: Partial<PrettyDurationOptions>
Format milliseconds to time duration.
Interfaces
I
Options for format.
- ignoreZero: boolean
Whether to ignore zero values. With style="narrow" | "full", all zero values are ignored. With style="digital", only values in the ends are ignored.
- style: "narrow" | "digital" | "full"
"narrow" for "0d 0h 0m 0s 0ms..." "digital" for "00:00:00:00:000..." "full" for "0 days, 0 hours, 0 minutes,..."