Skip to content

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

License

Notifications You must be signed in to change notification settings

IvoDeK/to-milliseconds

 
 

Repository files navigation

to-milliseconds Build Status

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

Install

$ npm install @sindresorhus/to-milliseconds

Usage

const toMilliseconds = require('@sindresorhus/to-milliseconds');

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

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

API

toMilliseconds(input)

input

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

License

MIT © Sindre Sorhus

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 88.7%
  • TypeScript 11.3%