Skip to main content
Module

std/fmt/duration.ts>format

The Deno Standard Library
Go to Latest
function format
import { format } from "https://deno.land/std@0.223.0/fmt/duration.ts";

Format milliseconds to time duration.

import { format } from "https://deno.land/std@0.223.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