npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

duration-i18n

v1.0.0

Published

Format durations and relative time in 100+ languages using the built-in Intl API — zero locale files. parse and ms() compatible. Tiny, tree-shakeable replacement for ms, humanize-duration and pretty-ms.

Readme

duration-i18n

npm size license

Format durations and "time ago" in 100+ languages — with zero locale files. Uses the built-in Intl API (NumberFormat units, ListFormat, RelativeTimeFormat), so every language your browser/Node supports works out of the box with correct plurals. Also parses durations and is a drop-in for ms.

import { formatDuration, formatRelative, parseDuration, ms } from 'duration-i18n';

formatDuration(3_725_000);                     // "1 hour, 2 minutes"
formatDuration(3_725_000, { locale: 'uz' });   // "1 soat 2 daqiqa"
formatDuration(3_725_000, { locale: 'ru' });   // "1 час 2 минуты"
formatDuration(93_000, { style: 'narrow' });   // "1m 33s"

formatRelative(Date.now() - 180_000, { locale: 'uz' }); // "3 daqiqa oldin"
formatRelative(Date.now() - 86_400_000, { locale: 'ru' }); // "вчера"

parseDuration('1h 30m');   // 5400000
parseDuration('PT15M');    // 900000 (ISO 8601)
ms('2 days');              // 172800000
ms(60000);                 // "1m"

Install

npm install duration-i18n

Why

| | duration-i18n | humanize-duration | pretty-ms | ms | date-fns formatDuration | | --- | --- | --- | --- | --- | --- | | Languages | all Intl locales | ~100 bundled | English | English | per-locale imports | | Locale data in your bundle | 0 KB | ~30 KB | – | – | per locale | | Relative time ("3 min ago") | ✅ | ❌ | ❌ | ❌ | separate fn | | Parse strings / ISO 8601 | ✅ | ❌ | ❌ | ✅ / ❌ | ❌ | | Tree-shakeable, TS types | ✅ | ❌ | ✅ | ✅ | ✅ |

API

formatDuration(ms, options?)

| Option | Default | Description | | --- | --- | --- | | locale | runtime locale | 'en', 'uz', 'ru', 'tr', 'de-DE', … | | style | 'long' | 'long' → "2 hours", 'short' → "2 hr", 'narrow' → "2h" | | largest | 2 | Max units shown | | units | year → second | Allowed units: year, month, week, day, hour, minute, second, millisecond | | round | true | Round the last unit (carries: 59 min 59.6 s → "1 hour") | | delimiter | locale list format | Custom separator |

formatRelative(date, options?)

date: timestamp, Date or ISO string. Options: locale, numeric ('auto' → "yesterday", 'always' → "1 day ago"), style, now.

parseDuration(text) → ms or NaN

"1h 30m", "1h30m", "1.5 hours", "2 days", "1 day, 2 hours and 3 minutes", "90s", "250ms", "500", "01:02:03", "2:30", "PT1H30M", "-5m".

ms(value) — ms package compatible

ms('2 days') → 172800000, ms(60000) → "1m", ms(60000, { long: true }) → "1 minute".

splitDuration(ms, units?)

splitDuration(90_061_000) → { day: 1, hour: 1, minute: 1, second: 1 }.

React example

function Uptime({ startedAt }: { startedAt: number }) {
  const { i18n } = useTranslation();
  return <span>{formatDuration(Date.now() - startedAt, { locale: i18n.language })}</span>;
}

Notes

  • Months are 30 days and years 365.25 days.
  • Needs Intl.NumberFormat unit support (all browsers since 2020, Node 14+ with full ICU — the default).

License

MIT