Convert an object of time properties to milliseconds:
{seconds: 2}
→2000
$ npm install @sindresorhus/to-milliseconds
const toMilliseconds = require('@sindresorhus/to-milliseconds');
toMilliseconds({
days: 15,
hours: 11,
minutes: 23,
seconds: 20,
milliseconds: 1
});
//=> 1337000001
setTimeout(() => {
// …
}, toMilliseconds({minutes: 2}));
Type: Object
Specify an object with any of the following properties:
days
hours
minutes
seconds
milliseconds
microseconds
nanoseconds
MIT © Sindre Sorhus