Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tpkn/string-to-ms
Module that converts the string into milliseconds
https://github.com/tpkn/string-to-ms
Last synced: 6 days ago
JSON representation
Module that converts the string into milliseconds
- Host: GitHub
- URL: https://github.com/tpkn/string-to-ms
- Owner: tpkn
- License: mit
- Created: 2017-12-12T17:22:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-13T14:07:08.000Z (over 6 years ago)
- Last Synced: 2024-11-14T14:32:23.090Z (2 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# String To Milliseconds
Module that converts the string into milliseconds. Understands following macross:| Time | Macros | Example |
| ------ | :------: | :------: |
| week | w | `7w` |
| day | d | `31d` |
| hour | h | `24h` |
| minute | m | `60m` |
| second | s | `60s` |Number without macros would be interpreted as milliseconds.
## Installation
```bash
npm install string-to-ms
```## Usage
```javascript
const stringToMs = require('string-to-ms');// return 1814400000
stringToMs(' 3w ');// return 43200000
stringToMs('0.5d');// return 43200000
stringToMs('12h');// return 600
stringToMs(600);// return 1371600000
stringToMs('1d 4d 10d 20h 1h');// return 202147207000
stringToMs('2335d 0112h 12112dsds 7s');
```## Changelog
#### 2017-12-17:
- Now works in browser too