@sindresorhus/to-milliseconds
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

to-milliseconds

Convert an object of time properties to milliseconds: {seconds: 2}2000

Install

$ npm install @sindresorhus/to-milliseconds

Usage

import toMilliseconds from '@sindresorhus/to-milliseconds';

toMilliseconds({
	days: 15,
	hours: 11,
	minutes: 23,
	seconds: 20,
	milliseconds: 1
});
//=> 1337000001

setTimeout(() => {
	// …
}, toMilliseconds({minutes: 2}));

API

toMilliseconds(timeDescriptor)

timeDescriptor

Type: object

Specify an object with any of the following properties:

  • days
  • hours
  • minutes
  • seconds
  • milliseconds
  • microseconds
  • nanoseconds

Related

  • parse-ms - The inverse of this module
  • pretty-ms - Convert milliseconds to a human readable string

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    995
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    995
  • 1.2.0
    70,295
  • 1.1.0
    0
  • 1.0.0
    1

Package Sidebar

Install

npm i @sindresorhus/to-milliseconds

Weekly Downloads

71,291

Version

2.0.0

License

MIT

Unpacked Size

4.22 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus