获取当前的时间是第几周

 // 獲取當前日期週數
    theWeek: function () {
      var totalDays = 0;
      var myDate = new Date();
      var year = myDate.getFullYear();
      var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
      _this.isLeapYear(year) ? days[1] = 29 : days[1] = 28;
      if (myDate.getMonth() == 0) {
        totalDays = totalDays + myDate.getDate();
      } else {
        var curMonth = myDate.getMonth();
        for (var count = 1; count <= curMonth; count++) {
          totalDays = totalDays + days[count - 1];
        }
        totalDays = totalDays + myDate.getDate()+new Date(year+'-01-01').getDay();
      }
      var week = Math.ceil(totalDays / 7);
      return week;
    },

 

你可能感兴趣的:(获取当前的时间是第几周)