Day.js 中文文档

当前版本 v1.11

更多文档

星期(区域设置感知)

根据区域设置获取或设置星期几。

需要配合 Weekday 插件才能工作

如果区域设置将星期日指定为一周的第一天,则 dayjs().weekday(0) 将是星期日。如果星期一是一周的第一天,则 dayjs().weekday(0) 将是星期一。

dayjs.extend(weekday)

// when Sunday is the first day of the week
dayjs().weekday(-7); // last Sunday
dayjs().weekday(7); // next Sunday

// when Monday is the first day of the week
dayjs().weekday(-7) // last Monday
dayjs().weekday(7) // next Monday

// when Sunday is the first day of the week
dayjs().weekday(-5) // last Tuesday (5th day before Sunday)
dayjs().weekday(5) // next Friday (5th day after Sunday)

Day.js 中文文档 - 粤ICP备14034220号-1