Skip to content

Repository files navigation

ms logo

@prsm/ms

Parse and convert time strings to milliseconds.

Installation

npm install @prsm/ms

Usage

importmsfrom"@prsm/ms"ms("1h 30m")// 5400000ms("15mins 12s")// 912000ms("1w 3d 12h")// 907200000ms("-30min")// -1800000ms(100)// 100

Options

ms("10.9ms")// 11 (rounded by default)ms("10.9ms",{round: false})// 10.9ms("1000ms",{unit: "s"})// 1ms("60s",{unit: "m"})// 1ms("90min",{unit: "h",round: false})// 1.5

Default Values

ms("",500)// 500ms(null,"1s")// 1000ms("invalid","5m")// 300000

Supported Units

UnitAliases
Millisecondsms, msec, msecs, millisecond, milliseconds
Secondss, sec, secs, second, seconds
Minutesm, mn, min, mins, minute, minutes
Hoursh, hr, hrs, hour, hours
Daysd, dy, day, days
Weeksw, wk, wks, week, weeks

License

Apache-2.0

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages