Moment.js 文档

星期几(区域设置感知) 2.1.0+

moment().weekday(Number);
moment().weekday(); // Number

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

如果语言环境将星期一指定为一周的第一天,则 moment().weekday(0) 将为星期一。 如果星期日是一周的第一天,则 moment().weekday(0) 将是星期日。

moment#day 一样,如果超出范围,就会冒泡到其他周。

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