You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
933 B

  1. # ms.js: miliseconds conversion utility
  2. ```js
  3. ms('2 days') // 172800000
  4. ms('1d') // 86400000
  5. ms('10h') // 36000000
  6. ms('2.5 hrs') // 9000000
  7. ms('2h') // 7200000
  8. ms('1m') // 60000
  9. ms('5s') // 5000
  10. ms('100') // 100
  11. ```
  12. ```js
  13. ms(60000) // "1m"
  14. ms(2 * 60000) // "2m"
  15. ms(ms('10 hours')) // "10h"
  16. ```
  17. ```js
  18. ms(60000, { long: true }) // "1 minute"
  19. ms(2 * 60000, { long: true }) // "2 minutes"
  20. ms(ms('10 hours'), { long: true }) // "10 hours"
  21. ```
  22. - Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download).
  23. - If a number is supplied to `ms`, a string with a unit is returned.
  24. - If a string that contains the number is supplied, it returns it as
  25. a number (e.g: it returns `100` for `'100'`).
  26. - If you pass a string with a number and a valid unit, the number of
  27. equivalent ms is returned.
  28. ## License
  29. MIT