Skip to content
string to milliseconds parser
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md
bower.json
msec.es.js
msec.js
msec.umd.js
package-lock.json
package.json
rollup.config.js
test.js

README.md

msec

string to milliseconds parser

Usage

'use strict';

let msec = require('msec');

setTimeout(() => {
    console.log('I execute after 1d 2h 37m 15s');
}, msec('1d 2h 37m 15s'));

setInterval(() => {
    console.log('I execute every 2 hours');
}, msec('2h'));

setTimeout(() => {
    console.log('I execute after 1h 3m 15s');
}, msec('5s 10s 1h 3m'));

new Date(Date.now() + msec('2d')); // same time, 2 days later

new Date(Date.now() + msec('2d 4h')); // 2 days and 4 hours later

Install (NPM)

$ npm install --save msec

Install (Bower)

$ bower install --save msec

Test

$ npm install && npm test
You can’t perform that action at this time.