Socket
Socket
Sign inDemoInstall

ms-human-format

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ms-human-format

Formats duration to and from human readable format


Version published
Maintainers
1
Install size
20.4 kB
Created

Readme

Source

Duration formatter and parser

This library helps to format duration to and from human readable format.

How to use

In NodeJS

import { parseDuration, formatMs } from "duration-formatter";

parseDuration("2hours 30 minutes, 20 sec 453ms") === 9020453;
formatMs(1296575243) === "2 weeks 1 day 9 minutes 35 seconds 243 milliseconds";

In the browser - not yet supported

More libraries like this one

  • Also duration formatter and parser, but for "hh:mm:ss" format from @cloudtion: https://www.npmjs.com/package/duration-formatter
  • If you need just to format duration from milliseconds in "hh:mm:ss" format (@ungoldman): https://www.npmjs.com/package/format-duration
  • Nice library to format milliseconds to human readable format, no parse though and only for esm (@sindresorhus): https://www.npmjs.com/package/pretty-ms
  • Duration formatter and parser as this library but esm and having lodash dependency (@nicolas-van): https://www.npmjs.com/package/simple-duration
  • Above one forked from this lib by @Raul-Tech-Support, but still with lodash dependency: https://www.npmjs.com/package/simple-duration-converter

Keywords

FAQs

Last updated on 02 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc