Zero dependencies · Node + CLI

Time durations, made human

Interpret, parse and format spans of time in days, hours, minutes, seconds and milliseconds. 7200 seconds becomes 2 hours — the way you'd actually say it.

node
> const Duration = require('@udlearn/duration')
> const d = new Duration({ hours: 1.5 })
> d.short
'1h 30m'
> d.medium
'1 hr 30 mins'
> d.long
'1 hour 30 minutes'
> d.format('%h hour(s) %m minute(s) ago')
'1 hour(s) 30 minute(s) ago'

Built for the way developers think about time

One small package. JavaScript or CLI. Familiar, predictable output.

Tiny & expressive API

Construct from any unit, decompose, or render in short, medium, or long English form.

Round-trip parsing

Parse '1.5h', '1 day 2 hours 3 minutes', or plain milliseconds back into a Duration.

Standalone CLI

Use as a Node CLI or a no-runtime binary via Homebrew, curl, or shell script.

Zero dependencies

Drop it in, ship it. No runtime weight, no surprise breaking changes.

Node.js

Drop into any JavaScript project

Install with npm and start formatting durations in seconds. Works with any ES module or CommonJS environment.

npm i @udlearn/duration

const Duration = require('@udlearn/duration')
Duration.parse('1.5h').medium  // '1 hr 30 mins'
Duration.from(3600, 'sec').long // '1 hour'

CLI

From the command line, instantly

Convert milliseconds, seconds, anything — straight from your shell. Node CLI or standalone binary, your choice.

$ duration 3600
3s 600ms

$ duration -m --unit=sec 3660
1 hr 1 min

$ DURATION_UNIT=sec duration --long 90
1 minute 30 seconds

Ready to humanize your timestamps?

Read the docs, try it live, or grab the source on GitHub.