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)
|
2 |
|
3 | <p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
|
4 | src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
|
5 | alt="Day.js"></a></p>
|
6 | <p align="center">Fast <b>2kB</b> alternative to Moment.js with the same modern API</p>
|
7 | <br>
|
8 | <p align="center">
|
9 | <a href="https://unpkg.com/dayjs/dayjs.min.js"><img
|
10 | src="http://img.badgesize.io/https://unpkg.com/dayjs/dayjs.min.js?compression=gzip&style=flat-square"
|
11 | alt="Gzip Size"></a>
|
12 | <a href="https://www.npmjs.com/package/dayjs"><img src="https://img.shields.io/npm/v/dayjs.svg?style=flat-square&colorB=51C838"
|
13 | alt="NPM Version"></a>
|
14 | <a href="https://travis-ci.org/iamkun/dayjs"><img
|
15 | src="https://img.shields.io/travis/iamkun/dayjs/master.svg?style=flat-square" alt="Build Status"></a>
|
16 | <a href="https://codecov.io/gh/iamkun/dayjs"><img
|
17 | src="https://img.shields.io/codecov/c/github/iamkun/dayjs/master.svg?style=flat-square" alt="Codecov"></a>
|
18 | <a href="https://github.com/iamkun/dayjs/blob/master/LICENSE"><img
|
19 | src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="License"></a>
|
20 | <br>
|
21 | <a href="https://saucelabs.com/u/dayjs">
|
22 | <img width="750" src="https://user-images.githubusercontent.com/17680888/40040137-8e3323a6-584b-11e8-9dba-bbe577ee8a7b.png" alt="Sauce Test Status">
|
23 | </a>
|
24 | </p>
|
25 |
|
26 | > 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.
|
27 |
|
28 | ```js
|
29 | dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
|
30 | ```
|
31 |
|
32 | * 🕒 Familiar Moment.js API & patterns
|
33 | * 💪 Immutable
|
34 | * 🔥 Chainable
|
35 | * 🌐 I18n support
|
36 | * 📦 2kb mini library
|
37 | * 👫 All browsers supported
|
38 |
|
39 | ---
|
40 |
|
41 | ## Getting Started
|
42 |
|
43 | ### Installation
|
44 |
|
45 | ```console
|
46 | npm install dayjs --save
|
47 | ```
|
48 |
|
49 | 📚[Installation Guide](./docs/en/Installation.md)
|
50 |
|
51 | ### API
|
52 |
|
53 | It's easy to use Day.js APIs to parse, validate, manipulate, and display dates and times.
|
54 |
|
55 | ```javascript
|
56 | dayjs('2018-08-08') // parse
|
57 |
|
58 | dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display
|
59 |
|
60 | dayjs().set('month', 3).month() // get & set
|
61 |
|
62 | dayjs().add(1, 'year') // manipulate
|
63 |
|
64 | dayjs().isBefore(dayjs()) // query
|
65 | ```
|
66 |
|
67 | 📚[API Reference](./docs/en/API-reference.md)
|
68 |
|
69 | ### I18n
|
70 |
|
71 | Day.js has great support for internationalization.
|
72 |
|
73 | But none of them will be included in your build unless you use it.
|
74 |
|
75 | ```javascript
|
76 | import 'dayjs/locale/es' // load on demand
|
77 |
|
78 | dayjs.locale('es') // use Spanish locale globally
|
79 |
|
80 | dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in a specific instance
|
81 | ```
|
82 | 📚[Internationalization](./docs/en/I18n.md)
|
83 |
|
84 | ### Plugin
|
85 |
|
86 | A plugin is an independent module that can be added to Day.js to extend functionality or add new features.
|
87 |
|
88 | ```javascript
|
89 | import advancedFormat from 'dayjs/plugin/advancedFormat' // load on demand
|
90 |
|
91 | dayjs.extend(advancedFormat) // use plugin
|
92 |
|
93 | dayjs().format('Q Do k kk X x') // more available formats
|
94 | ```
|
95 |
|
96 | 📚[Plugin List](./docs/en/Plugin.md)
|
97 |
|
98 | ## Sponsors
|
99 |
|
100 | Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/dayjs#sponsor)]
|
101 |
|
102 | <a href="https://opencollective.com/dayjs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/0/avatar.svg"></a>
|
103 | <a href="https://opencollective.com/dayjs/sponsor/1/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/1/avatar.svg"></a>
|
104 | <a href="https://opencollective.com/dayjs/sponsor/2/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/2/avatar.svg"></a>
|
105 | <a href="https://opencollective.com/dayjs/sponsor/3/website" target="_blank"><img src="https://opencollective.com/dayjs/sponsor/3/avatar.svg"></a>
|
106 |
|
107 | ## Contributors
|
108 |
|
109 | This project exists thanks to all the people who contribute.
|
110 |
|
111 | Please give us a 💖 star 💖 to support us. Thank you.
|
112 |
|
113 | And thank you to all our backers! 🙏
|
114 |
|
115 | <a href="https://opencollective.com/dayjs/backer/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/dayjs/backer/0/avatar.svg?requireActive=false"></a>
|
116 | <a href="https://opencollective.com/dayjs/backer/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/dayjs/backer/1/avatar.svg?requireActive=false"></a>
|
117 | <a href="https://opencollective.com/dayjs/backer/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/dayjs/backer/2/avatar.svg?requireActive=false"></a>
|
118 | <a href="https://opencollective.com/dayjs/backer/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/dayjs/backer/3/avatar.svg?requireActive=false"></a>
|
119 | <a href="https://opencollective.com/dayjs#backers" target="_blank"><img src="https://opencollective.com/dayjs/contributors.svg?width=890" /></a>
|
120 |
|
121 | ## License
|
122 |
|
123 | Day.js is licensed under a [MIT License](./LICENSE).
|