|
2 | 2 | id: advanced-format |
3 | 3 | title: AdvancedFormat |
4 | 4 | --- |
| 5 | + |
5 | 6 | AdvancedFormat extends `dayjs().format` API to supply more format options. |
6 | 7 |
|
7 | 8 | ```javascript |
8 | | -var advancedFormat = require('dayjs/plugin/advancedFormat') |
9 | | -dayjs.extend(advancedFormat) |
| 9 | +var advancedFormat = require("dayjs/plugin/advancedFormat"); |
| 10 | +// import advancedFormat from 'dayjs/plugin/advancedFormat' // ES 2015 |
| 11 | + |
| 12 | +dayjs.extend(advancedFormat); |
10 | 13 |
|
11 | | -dayjs().format('Q Do k kk X x') |
| 14 | +dayjs().format("Q Do k kk X x"); |
12 | 15 | ``` |
13 | 16 |
|
14 | 17 | Note: some of the format options like `z` and `zzz` in the table below require additional plugins. |
15 | 18 |
|
16 | 19 | List of added formats: |
17 | 20 |
|
18 | | -| Format | Output | Description | |
19 | | -| ------ | --------------------- | ----------------------------------------------------- | |
20 | | -| `Q` | 1-4 | Quarter | |
21 | | -| `Do` | 1st 2nd ... 31st | Day of Month with ordinal | |
22 | | -| `k` | 1-24 | The hour, beginning at 1 | |
23 | | -| `kk` | 01-24 | The hour, 2-digits, beginning at 1 | |
24 | | -| `X` | 1360013296 | Unix Timestamp in second | |
25 | | -| `x` | 1360013296123 | Unix Timestamp in millisecond | |
26 | | -| `w` | 1 2 ... 52 53 | Week of year @>>WeekOfYear | |
27 | | -| `ww` | 01 02 ... 52 53 | Week of year, 2-digits @>>WeekOfYear | |
28 | | -| `W` | 1 2 ... 52 53 | ISO Week of year @>>IsoWeek | |
29 | | -| `WW` | 01 02 ... 52 53 | ISO Week of year, 2-digits @>>IsoWeek | |
30 | | -| `wo` | 1st 2nd ... 52nd 53rd | Week of year with ordinal @>>WeekOfYear | |
31 | | -| `gggg` | 2017 | Week Year @>>WeekYear | |
32 | | -| `GGGG` | 2017 | ISO Week Year @>>IsoWeek | |
33 | | -| `z` | EST | Abbreviated named offset @>>Timezone | |
34 | | -| `zzz` | Eastern Standard Time | Unabbreviated named offset @>>Timezone | |
| 21 | +| Format | Output | Description | |
| 22 | +| ------ | --------------------- | --------------------------------------- | |
| 23 | +| `Q` | 1-4 | Quarter | |
| 24 | +| `Do` | 1st 2nd ... 31st | Day of Month with ordinal | |
| 25 | +| `k` | 1-24 | The hour, beginning at 1 | |
| 26 | +| `kk` | 01-24 | The hour, 2-digits, beginning at 1 | |
| 27 | +| `X` | 1360013296 | Unix Timestamp in second | |
| 28 | +| `x` | 1360013296123 | Unix Timestamp in millisecond | |
| 29 | +| `w` | 1 2 ... 52 53 | Week of year @>>WeekOfYear | |
| 30 | +| `ww` | 01 02 ... 52 53 | Week of year, 2-digits @>>WeekOfYear | |
| 31 | +| `W` | 1 2 ... 52 53 | ISO Week of year @>>IsoWeek | |
| 32 | +| `WW` | 01 02 ... 52 53 | ISO Week of year, 2-digits @>>IsoWeek | |
| 33 | +| `wo` | 1st 2nd ... 52nd 53rd | Week of year with ordinal @>>WeekOfYear | |
| 34 | +| `gggg` | 2017 | Week Year @>>WeekYear | |
| 35 | +| `GGGG` | 2017 | ISO Week Year @>>IsoWeek | |
| 36 | +| `z` | EST | Abbreviated named offset @>>Timezone | |
| 37 | +| `zzz` | Eastern Standard Time | Unabbreviated named offset @>>Timezone | |
0 commit comments