UNPKG

3.46 kBMarkdownView Raw
1English | [įŽ€äŊ“中文](./README.zh-CN.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"
13 alt="NPM Version"></a>
14 <a href="https://travis-ci.org/xx45/dayjs"><img
15 src="https://img.shields.io/travis/xx45/dayjs/master.svg?style=flat-square" alt="Build Status"></a>
16 <a href="https://codecov.io/gh/xx45/dayjs"><img
17 src="https://img.shields.io/codecov/c/github/xx45/dayjs/master.svg?style=flat-square" alt="Codecov"></a>
18 <a href="https://github.com/xx45/dayjs/blob/master/LICENSE"><img
19 src="https://img.shields.io/npm/l/dayjs.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
29dayjs().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
46npm install dayjs --save
47```
48
49📚[Installation Guide](./docs/en/Installation.md)
50
51### API
52
53It's easy to use Day.js APIs to parse, validate, manipulate, and display dates and times.
54
55```javascript
56dayjs('2018-08-08') // parse
57
58dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display
59
60dayjs().set('month', 3).month() // get & set
61
62dayjs().add(1, 'year') // manipulate
63
64dayjs().isBefore(dayjs()) // query
65```
66
67📚[API Reference](./docs/en/API-reference.md)
68
69### I18n
70
71Day.js has great support for internationalization.
72
73But none of them will be included in your build unless you use it.
74
75```javascript
76import 'dayjs/locale/es' // load on demand
77
78dayjs.locale('es') // use Spanish locale globally
79
80dayjs('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
86A plugin is an independent module that can be added to Day.js to extend functionality or add new features.
87
88```javascript
89import AdvancedFormat from 'dayjs/plugin/AdvancedFormat' // load on demand
90
91dayjs.extend(AdvancedFormat) // use plugin
92
93dayjs().format('Q Do k kk X x') // more available formats
94```
95📚[Plugin List](./docs/en/Plugin.md)
96
97## License
98
99Day.js is licensed under a [MIT License](./LICENSE).
\No newline at end of file