相关疑难解决方法(0)

Moment.js - 周一以isoWeekday()开始一周

我正在创建一个日历,我以表格格式打印周.一个要求是,我可以根据某些用户选项在周一或周日开始这几周.我很难使用moment的isoWeekday方法.

// Start of some date range. Can be any day of the week.
var startOfPeriod = moment("2013-06-23T00:00:00"),

    // We begin on the start of the first week.
    // Mon Tues Wed Thur Fri Sat Sun
    // 20  21   22  23   24  25  26
    begin = moment(startOfPeriod).isoWeekday(1); // will pull from user setting

console.log(begin.isoWeekday()); // 1 - all good

// Let's get the beginning of this first week, respecting the isoWeekday
begin.startOf('week');

console.log(begin.isoWeekday()); // 7 - what happened …
Run Code Online (Sandbox Code Playgroud)

javascript momentjs

107
推荐指数
3
解决办法
11万
查看次数

标签 统计

javascript ×1

momentjs ×1