Converts CSS-style durations to milliseconds.
var duration = require("css-duration")
duration('1000ms')
// > 1000
duration('1.5s')
// > 1500
duration('30m')
// > 1800000
duration('8h')
// > 28800000
duration('2d')
// > 172800000
npm install --save css-duration
Normalizes "unit-based time" (similar to CSS values) into a Number
of milliseconds.
time
(String
): A CSS-style value of a duration of time (i.e.10s
,5h
,0.5d
)
ms
: Millisecondss
: Secondsh
: Hoursd
: Daysw
: Weeks
Note: Anything past seconds is not a valid CSS unit. Use another package for validating.
duration('0.25d')
// => 21600000
duration('-1w')
// => -604800000
MIT © Brandon Semilla