Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

stringtime

piedema13MIT2.0.2

module to convert stringtime to milliseconds and vice versa

string time, milliseconds, ms to array, ms to object, ms to string, array to ms, object to ms, string to ms, convert time

readme

stringtime

This module lets you convert passed time in milliseconds to a String, Object or Array representation or vice versa.

Installation

npm install stringtime

Getting started

const st = require('stringtime');

Getting string version of milliseconds

let string = st.toString(6185000);
console.log(string); // 1h 43min 5s

Getting object version of milliseconds

let object = st.toObject(6185000);
console.log(object); // { h:1, min:43, s:5 }

Getting array version of milliseconds

let array = st.toArray(6185000);
console.log(array); // [ '1h', '43min', '5s' ]

Getting milliseconds of array, string, object

let milliseconds = st.toMs(['57min', '1h', '5s']);
console.log(milliseconds); // 7025000

let milliseconds2 = st.toMs('57min 1h 5s');
console.log(milliseconds2); // 7025000

let milliseconds3 = st.toMs({ min:57, h:1, s:5 });
console.log(milliseconds3); // 7025000

Result on invalid input

Invalid input

Timeframes

ML: Millennium
C: Century
DEC: Decade
YR: Year
WK: Week
D: Day
h: Hour
min: Minute
s: Second
ms: Millisecond