Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/fmt/duration.ts>format

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function format
import { format } from "https://deno.land/std@0.215.0/fmt/duration.ts";

Format milliseconds to time duration.

import { format } from "https://deno.land/std@0.215.0/fmt/duration.ts";

format(99674, { style: "digital" }); // "00:00:01:39:674:000:000"
format(99674); // "0d 0h 1m 39s 674ms 0µs 0ns"
format(99674, { ignoreZero: true }); // "1m 39s 674ms"
format(99674, { style: "full", ignoreZero: true }); // "1 minutes, 39 seconds, 674 milliseconds"

Parameters

ms: number
optional
options: Partial<PrettyDurationOptions> = [UNSUPPORTED]

Returns

string