Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 13, 2024 via pnpm

ms 2.1.2

Tiny millisecond conversion utility
Package summary
Share
0
issues
1
license
1
MIT
Package created
21 Dec 2011
Version published
6 Jun 2019
Maintainers
7
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
ms@2.1.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of ms 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does ms do?

The 'ms' npm package is a diminutive utility designed for the express purpose of converting various time formats into milliseconds. This tool is handy in situations where calculations or operations integral to the function of your program or application require input in the form of milliseconds. The 'ms' package works on both Node.js and in-browser environments, robustly interpreting a variety of time expressions. For example, it can convert full written-out time durations - '2 days', '1 hour', etc - and abbreviated inputs - '1d', '10h', etc.

How do you use ms?

Usage of the 'ms' library is refreshingly straightforward. It can be invoked within your JavaScript code by simply calling the ms() function. This function takes one mandatory argument, which is the time duration (in any format) that you want to convert to milliseconds. Additionally, there is an optional argument that configures whether the output should be in a long-fully-written-out format.

Here are examples to demonstrate how to use 'ms':

To get the equivalent milliseconds for a time duration:

const ms = require('ms');
console.log(ms('2 days'));  // Outputs: 172800000
console.log(ms('1d'));      // Outputs: 86400000
console.log(ms('10h'));     // Outputs: 36000000

To convert from milliseconds to time duration:

console.log(ms(60000));             // Outputs: "1m"
console.log(ms(2 * 60000));         // Outputs: "2m"
console.log(ms(-3 * 60000));        // Outputs: "-3m"
console.log(ms(ms('10 hours')));    // Outputs: "10h"

To get the converted duration in a long format:

console.log(ms(60000, { long: true }));             // Outputs: "1 minute"
console.log(ms(2 * 60000, { long: true }));         // Outputs: "2 minutes"
console.log(ms(-3 * 60000, { long: true }));        // Outputs: "-3 minutes"
console.log(ms(ms('10 hours'), { long: true }));    // Outputs: "10 hours"

Where are the ms docs?

The 'ms' package's documentation can be found within its readme on the official GitHub page of the package. The link to the page is https://github.com/vercel/ms. The readme contains comprehensive information on the usage of the 'ms' package in various cases, as well as details on features and examples of code snippets.