date-ms

date string to ms convertion lib

npm install date-ms
9 downloads in the last week
19 downloads in the last month

date-ms build status

Milliseconds conversion utility, inspired by guille/ms.js

Installation

npm install date-ms
bower install date-ms

Usage

var ms = require('date-ms');

ms('1d')        // 86400000
ms('10h')       // 36000000
ms('2h')        // 7200000
ms('1m')        // 60000
ms('5s')        // 5000
ms('100')       // 100

ms(1000)        // 1000
ms()            // +new Date()
ms('')          // +new Date()
ms(null)        // +new Date()
ms(undefined)   // +new Date()

ms( new Date('2013-04-05') )                    // 1365120000000
ms('2013-04-05')                                // 1365120000000
ms('2013-04-09T13:45+0400')                     // 1365500700000
ms('Thu May 16 2013 00:47:53 GMT+0400 (MSK)')   // 1368650873000

ms.tz           // -14400000

// start of day in user's timezone
ms.sod('2013-06-17T12:02:40+0400')   // +new Date('2013-06-17T00:00:00+0400')

License

MIT

npm loves you