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

@scuton/ms-convert

v1.0.0

Published

Convert between human-readable time strings and milliseconds. Bidirectional.

Readme

@scuton/ms-convert

Convert between human-readable time strings and milliseconds. Bidirectional.

Installation

npm install @scuton/ms-convert

Usage

import { toMs, toHuman } from '@scuton/ms-convert';

// String to milliseconds
toMs('2h 30m');    // 9000000
toMs('1d 12h');    // 129600000
toMs('1.5h');      // 5400000
toMs('500ms');     // 500
toMs('1mo');       // 2592000000
toMs('1y');        // 31536000000

// Milliseconds to human-readable string
toHuman(9000000);                        // '2h 30m'
toHuman(129600000);                      // '1d 12h'
toHuman(90061000);                       // '1d 1h 1m 1s'

// Short format (largest unit only)
toHuman(90061000, { short: true });      // '1d'

// Long format (full words)
toHuman(3600000, { long: true });        // '1 hour'
toHuman(7200000, { long: true });        // '2 hours'

API

toMs(input: string): number

Converts a human-readable time string to milliseconds.

  • Supports compound strings like '2h 30m'
  • Supports decimal values like '1.5h'
  • Case insensitive
  • Throws Error if no valid time units are found

toHuman(ms: number, options?: ToHumanOptions): string

Converts milliseconds to a human-readable string.

Options

| Option | Type | Default | Description | |---------|-----------|---------|--------------------------------------| | short | boolean | false | Return only the largest unit | | long | boolean | false | Use full unit names (e.g., "hours") |

Supported Units

| Unit | Short | Long | Milliseconds | |------|-------|--------------|--------------------| | ms | ms | millisecond | 1 | | s | s | second | 1,000 | | m | m | minute | 60,000 | | h | h | hour | 3,600,000 | | d | d | day | 86,400,000 | | w | w | week | 604,800,000 | | mo | mo | month | 2,592,000,000 (30d)| | y | y | year | 31,536,000,000(365d)|

License

MIT - Scuton Technology