AdvancedFormat
AdvancedFormat 扩展了 `dayjs().format` API 以提供更多格式选项。
var advancedFormat = require('dayjs/plugin/advancedFormat')
dayjs.extend(advancedFormat)
dayjs().format('Q Do k kk X x')
注意: 下表中的一些格式选项(例如 z
和 zzz
)需要额外的插件。
添加格式列表:
格式 | 输出 | 描述 |
---|---|---|
Q | 1-4 | 季度 |
Do | 1st 2nd ... 31st | 带序数的月份中的某一天 |
k | 1-24 | 小时,从 1 开始 |
kk | 01-24 | 小时,2 位数字,从 1 开始 |
X | 1360013296 | Unix 时间戳(秒) |
x | 1360013296123 | Unix 时间戳(以毫秒为单位) |
w | 1 2 ... 52 53 | Week of year (
dependent
一年中的一周
plugin
) |
ww | 01 02 ... 52 53 | Week of year, 2-digits (
dependent
一年中的一周
plugin
) |
W | 1 2 ... 52 53 | ISO Week of year (
dependent
等周
plugin
) |
WW | 01 02 ... 52 53 | ISO Week of year, 2-digits (
dependent
等周
plugin
) |
wo | 1st 2nd ... 52nd 53rd | Week of year with ordinal (
dependent
一年中的一周
plugin
) |
gggg | 2017 | Week Year (
dependent
周年
plugin
) |
GGGG | 2017 | ISO Week Year (
dependent
等周
plugin
) |
z | EST | Abbreviated named offset (
dependent
Timezone
plugin
) |
zzz | 东部标准时间 | Unabbreviated named offset (
dependent
Timezone
plugin
) |