1 | English | [įŽäŊä¸æ](./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
|
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 | đ[Plugin List](./docs/en/Plugin.md)
|
96 |
|
97 | ## License
|
98 |
|
99 | Day.js is licensed under a [MIT License](./LICENSE). |
\ | No newline at end of file |