A simple utility to parse a duration string into milliseconds number.
yarn add @alwatr/parse-duration
import {parseDuration} from '@alwatr/parse-duration';
parseDuration('10s'); // 10,000
parseDuration('10m'); // 600,000
parseDuration('10h'); // 36,000,000
parseDuration('10d'); // 864,000,000
parseDuration('10w'); // 6,048,000,000
parseDuration('10M'); // 25,920,000,000
parseDuration('10y'); // 315,360,000,000
parseDuration('10d', 'h'); // 240
Unit | Description |
---|---|
s |
Second |
m |
Minute |
h |
Hour |
d |
Day |
w |
Week |
M |
Month |
y |
Year |
The following companies, organizations, and individuals support Nanolib ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.
Contributions are welcome! Please read our contribution guidelines before submitting a pull request.
This project is licensed under the AGPL-3.0 License.