duration-format

JSON →
library 0.0.2 ·javascript
verified Jun 4, 2026

A lightweight JavaScript library for formatting durations (milliseconds) into human-readable strings using template patterns with placeholders for days, hours, minutes, seconds, and milliseconds. Version 0.0.2 is the latest and only release, with no active development. It differs from other duration formatters (e.g., moment.js duration, Intl.RelativeTimeFormat) by offering a simple, pattern-based syntax inspired by Ruby's String#% and does not depend on any external libraries. The library works in both Node.js and browser environments and supports zero-padding via number prefix in placeholders.