UNPKG

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