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.

172 lines
7.7 KiB

1 month ago
  1. English | [简体中文](./docs/zh-cn/README.zh-CN.md) | [日本語](./docs/ja/README-ja.md) | [Português Brasileiro](./docs/pt-br/README-pt-br.md) | [한국어](./docs/ko/README-ko.md) | [Español (España)](./docs/es-es/README-es-es.md) | [Русский](./docs/ru/README-ru.md) | [Türkçe](./docs/tr/README-tr.md) | [සිංහල](./docs/si/README-si.md) | [עברית](./docs/he/README-he.md)
  2. <p align="center"><a href="https://day.js.org/" target="_blank" rel="noopener noreferrer"><img width="550"
  3. src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
  4. alt="Day.js" /></a></p>
  5. <p align="center">Fast <b>2kB</b> alternative to Moment.js with the same modern API</p>
  6. <p align="center">
  7. <a href="https://bundlephobia.com/package/dayjs"><img
  8. src="https://img.shields.io/bundlephobia/minzip/dayjs?style=flat-square&color=%2345cc11"
  9. alt="Gzip Size"></a>
  10. <a href="https://www.npmjs.com/package/dayjs"><img src="https://img.shields.io/npm/v/dayjs.svg?style=flat-square&colorB=51C838"
  11. alt="NPM Version"></a>
  12. <a href="https://github.com/iamkun/dayjs/actions/workflows/check.yml"><img
  13. src="https://img.shields.io/github/actions/workflow/status/iamkun/dayjs/check.yml?style=flat-square" alt="Build Status"></a>
  14. <a href="https://codecov.io/gh/iamkun/dayjs"><img
  15. src="https://img.shields.io/codecov/c/github/iamkun/dayjs/master.svg?style=flat-square" alt="Codecov"></a>
  16. <a href="https://github.com/iamkun/dayjs/blob/master/LICENSE"><img
  17. src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="License"></a>
  18. <br>
  19. <a href="https://saucelabs.com/u/dayjs">
  20. <img width="750" src="https://user-images.githubusercontent.com/17680888/40040137-8e3323a6-584b-11e8-9dba-bbe577ee8a7b.png" alt="Sauce Test Status">
  21. </a>
  22. </p>
  23. > Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API. If you use Moment.js, you already know how to use Day.js.
  24. ```js
  25. dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
  26. ```
  27. * 🕒 Familiar Moment.js API & patterns
  28. * 💪 Immutable
  29. * 🔥 Chainable
  30. * 🌐 I18n support
  31. * 📦 2kb mini library
  32. * 👫 All browsers supported
  33. ---
  34. ## Getting Started
  35. ### Documentation
  36. You can find more details, API, and other docs on [day.js.org](https://day.js.org/) website.
  37. ### Installation
  38. ```console
  39. npm install dayjs --save
  40. ```
  41. 📚[Installation Guide](https://day.js.org/docs/en/installation/installation)
  42. ### API
  43. It's easy to use Day.js APIs to parse, validate, manipulate, and display dates and times.
  44. ```javascript
  45. dayjs('2018-08-08') // parse
  46. dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display
  47. dayjs().set('month', 3).month() // get & set
  48. dayjs().add(1, 'year') // manipulate
  49. dayjs().isBefore(dayjs()) // query
  50. ```
  51. 📚[API Reference](https://day.js.org/docs/en/parse/parse)
  52. ### I18n
  53. Day.js has great support for internationalization.
  54. But none of them will be included in your build unless you use it.
  55. ```javascript
  56. import 'dayjs/locale/es' // load on demand
  57. dayjs.locale('es') // use Spanish locale globally
  58. dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in a specific instance
  59. ```
  60. 📚[Internationalization](https://day.js.org/docs/en/i18n/i18n)
  61. ### Plugin
  62. A plugin is an independent module that can be added to Day.js to extend functionality or add new features.
  63. ```javascript
  64. import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand
  65. dayjs.extend(advancedFormat) // use plugin
  66. dayjs().format('Q Do k kk X x') // more available formats
  67. ```
  68. 📚[Plugin List](https://day.js.org/docs/en/plugin/plugin)
  69. ### Usage Trend
  70. <a href="https://npm-compare.com/moment,dayjs/#timeRange=THREE_YEARS" target="_blank">
  71. <img src="https://user-images.githubusercontent.com/3455798/270162667-c7bd2ebe-675e-45c6-a2c9-dc67f3b65d6e.png">
  72. </a>
  73. ## Sponsors
  74. Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
  75. [[Become a sponsor via Github](https://github.com/sponsors/iamkun/)] [[Become a sponsor via OpenCollective](https://opencollective.com/dayjs#sponsor)]
  76. <a href="https://toyokumo.co.jp" target="_blank">
  77. <img width="70" src="https://user-images.githubusercontent.com/17680888/197092231-2367b5eb-1e43-467e-a311-23f7cd97b086.png">
  78. </a>
  79. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  80. <a href="https://github.com/ken-swyfft" target="_blank">
  81. <img width="70" src="https://avatars.githubusercontent.com/u/65305317?v=4">
  82. </a>
  83. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  84. <a href="https://opencollective.com/sight-and-sound-ministries" target="_blank">
  85. <img width="70" src="https://user-images.githubusercontent.com/17680888/232316426-cb99b4cf-0ccb-4e73-a6ce-e16dba6aadf4.png">
  86. </a>
  87. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  88. <a href="https://chudovo.com/" target="_blank">
  89. <img width="70" src="https://images.opencollective.com/chudovo/3c866f5/logo/256.png?height=256">
  90. </a>
  91. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  92. <a href="https://www.honrev.com" target="_blank">
  93. <img width="70" src="https://github.com/user-attachments/assets/b3203350-34c1-4637-b8b1-d9b8bab346d3">
  94. </a>
  95. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  96. <a href="https://github.com/alan-eu" target="_blank">
  97. <img width="70" src="https://avatars.githubusercontent.com/u/18175329?s=52&v=4">
  98. </a>
  99. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  100. <a href="https://www.exoflare.com/open-source/?utm_source=dayjs&utm_campaign=open_source" target="_blank">
  101. <img width="70" src="https://user-images.githubusercontent.com/17680888/162761622-1407a849-0c41-4591-8aa9-f98114ec2092.png">
  102. </a>
  103. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  104. <a href="https://github.com/storyblok" target="_blank">
  105. <img width="70" src="https://avatars.githubusercontent.com/u/13880908?s=200&v=4">
  106. </a>
  107. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  108. <a href="https://bestkru.com/" target="_blank">
  109. <img width="70" src="https://avatars.githubusercontent.com/u/159320286" alt="BestKru">
  110. </a>
  111. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  112. <a href="https://route4me.com/" target="_blank">
  113. <img width="70" src="https://github.com/user-attachments/assets/3fbc86c5-98a9-49c2-beae-1969026fcd76" alt="Route Optimizer and Route Planner Software">
  114. </a>
  115. ## Contributors
  116. This project exists thanks to all the people who contribute.
  117. Please give us a 💖 star 💖 to support us. Thank you.
  118. And thank you to all our backers! 🙏
  119. <a href="https://opencollective.com/dayjs/backer/0/website?requireActive=false" target="_blank"><img width="35" src="https://opencollective.com/dayjs/backer/0/avatar.svg?requireActive=false"></a>
  120. <a href="https://opencollective.com/dayjs/backer/1/website?requireActive=false" target="_blank"><img width="35" src="https://opencollective.com/dayjs/backer/1/avatar.svg?requireActive=false"></a>
  121. <a href="https://opencollective.com/dayjs/backer/2/website?requireActive=false" target="_blank"><img width="35" src="https://opencollective.com/dayjs/backer/2/avatar.svg?requireActive=false"></a>
  122. <a href="https://opencollective.com/dayjs/backer/3/website?requireActive=false" target="_blank"><img width="35" src="https://opencollective.com/dayjs/backer/3/avatar.svg?requireActive=false"></a>
  123. <br />
  124. <a href="https://opencollective.com/dayjs#backers" target="_blank"><img src="https://opencollective.com/dayjs/contributors.svg?width=890" /></a>
  125. ## License
  126. Day.js is licensed under a [MIT License](./LICENSE).