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.

README.md 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # time-stamp [![NPM version](https://img.shields.io/npm/v/time-stamp.svg?style=flat)](https://www.npmjs.com/package/time-stamp) [![NPM monthly downloads](https://img.shields.io/npm/dm/time-stamp.svg?style=flat)](https://npmjs.org/package/time-stamp) [![NPM total downloads](https://img.shields.io/npm/dt/time-stamp.svg?style=flat)](https://npmjs.org/package/time-stamp) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/time-stamp.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/time-stamp)
  2. > Get a formatted timestamp.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install --save time-stamp
  7. ```
  8. ## Usage
  9. ```js
  10. var timestamp = require('time-stamp');
  11. timestamp();
  12. //=> 2017:05:14
  13. timestamp('YYYYMMDD');
  14. //=> 20170514
  15. timestamp('YYYYMMDD:ss');
  16. //=> 20170514:26
  17. timestamp('YYYY/MM/DD:mm:ss');
  18. //=> 2017/05/14:52:26
  19. timestamp('YYYY:MM:DD');
  20. //=> 2017:05:14
  21. timestamp('[YYYY:MM:DD]');
  22. //=> [2017:05:14]
  23. timestamp('YYYY/MM/DD');
  24. //=> 2017/05/14
  25. timestamp('YYYY:MM');
  26. //=> 2017:05
  27. timestamp('YYYY');
  28. //=> 2017
  29. timestamp('MM');
  30. //=> 05
  31. timestamp('DD');
  32. //=> 14
  33. timestamp('HH');
  34. //=> 20
  35. timestamp('mm');
  36. //=> 52
  37. timestamp('ss');
  38. //=> 26
  39. timestamp('ms');
  40. //=> 481
  41. ```
  42. **Valid patterns**
  43. * `YYYY`: full year (ex: **2017**)
  44. * `MM`: month (ex: **04**)
  45. * `DD`: day (ex: **01**)
  46. * `HH`: hours (ex: **12**)
  47. * `mm`: minutes (ex: **59**)
  48. * `ss`: seconds (ex: **09**)
  49. * `ms`: milliseconds (ex: **532**)
  50. ## About
  51. ### Related projects
  52. * [days](https://www.npmjs.com/package/days): Days of the week. | [homepage](https://github.com/jonschlinkert/days "Days of the week.")
  53. * [iso-week](https://www.npmjs.com/package/iso-week): Get the ISO week of the year. | [homepage](https://github.com/jonschlinkert/iso-week "Get the ISO week of the year.")
  54. * [month](https://www.npmjs.com/package/month): Get the name or number of the current month or any month of the year. | [homepage](https://github.com/datetime/month "Get the name or number of the current month or any month of the year.")
  55. * [months](https://www.npmjs.com/package/months): Months of the year. | [homepage](https://github.com/jonschlinkert/months "Months of the year.")
  56. * [o-clock](https://www.npmjs.com/package/o-clock): Simple javascript utility for displaying the time in 12-hour clock format. | [homepage](https://github.com/jonschlinkert/o-clock "Simple javascript utility for displaying the time in 12-hour clock format.")
  57. * [seconds](https://www.npmjs.com/package/seconds): Get the number of seconds for a minute, hour, day and week. | [homepage](https://github.com/jonschlinkert/seconds "Get the number of seconds for a minute, hour, day and week.")
  58. * [week](https://www.npmjs.com/package/week): Get the current week number. | [homepage](https://github.com/datetime/week "Get the current week number.")
  59. * [weekday](https://www.npmjs.com/package/weekday): Get the name and number of the current weekday. Or get the name of the… [more](https://github.com/datetime/weekday) | [homepage](https://github.com/datetime/weekday "Get the name and number of the current weekday. Or get the name of the weekday for a given number.")
  60. * [year](https://www.npmjs.com/package/year): Simple utility to get the current year with 2 or 4 digits. | [homepage](https://github.com/jonschlinkert/year "Simple utility to get the current year with 2 or 4 digits.")
  61. ### Contributing
  62. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  63. ### Contributors
  64. | **Commits** | **Contributor** |
  65. | --- | --- |
  66. | 21 | [jonschlinkert](https://github.com/jonschlinkert) |
  67. | 1 | [evocateur](https://github.com/evocateur) |
  68. | 1 | [mendenhallmagic](https://github.com/mendenhallmagic) |
  69. ### Building docs
  70. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  71. To generate the readme, run the following command:
  72. ```sh
  73. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  74. ```
  75. ### Running tests
  76. Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
  77. ```sh
  78. $ npm install && npm test
  79. ```
  80. ### Author
  81. **Jon Schlinkert**
  82. * [github/jonschlinkert](https://github.com/jonschlinkert)
  83. * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  84. ### License
  85. Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
  86. Released under the [MIT License](LICENSE).
  87. ***
  88. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 14, 2017._