AdvancedFormat
AdvancedFormat extends dayjs().format
API to supply more format options.
javascript
var advancedFormat = require('dayjs/plugin/advancedFormat');
// import advancedFormat from 'dayjs/plugin/advancedFormat' // ES 2015
dayjs.extend(advancedFormat);
dayjs().format('Q Do k kk X x');
Note: some of the format options like z
and zzz
in the table below require additional plugins.
List of added formats:
Format | Output | Description |
---|---|---|
Q | 1-4 | Quarter |
Do | 1st 2nd ... 31st | Day of Month with ordinal |
k | 1-24 | The hour, beginning at 1 |
kk | 01-24 | The hour, 2-digits, beginning at 1 |
X | 1360013296 | Unix Timestamp in second |
x | 1360013296123 | Unix Timestamp in millisecond |
w | 1 2 ... 52 53 | Week of year ( dependent WeekOfYear plugin ) |
ww | 01 02 ... 52 53 | Week of year, 2-digits ( dependent WeekOfYear plugin ) |
W | 1 2 ... 52 53 | ISO Week of year ( dependent IsoWeek plugin ) |
WW | 01 02 ... 52 53 | ISO Week of year, 2-digits ( dependent IsoWeek plugin ) |
wo | 1st 2nd ... 52nd 53rd | Week of year with ordinal ( dependent WeekOfYear plugin ) |
gggg | 2017 | Week Year ( dependent WeekYear plugin ) |
GGGG | 2017 | ISO Week Year ( dependent IsoWeek plugin ) |
z | EST | Abbreviated named offset ( dependent Timezone plugin ) |
zzz | Eastern Standard Time | Unabbreviated named offset ( dependent Timezone plugin ) |