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

std/fmt/duration.ts

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
import * as mod from "https://deno.land/std@0.208.0/fmt/duration.ts";

Format milliseconds to time duration.

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

// "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 });