javascript获取当前月每天的日期和星期

let date = new Date();
  let year = date.getFullYear();//获取当前年份
  let month = date.getMonth() + 1;//获取当前月
  let dd = new Date(year, month, 0);//获取当月总天数
  let current_month = [];
  let weekList = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  for (let i = 1; i <= dd.getDate(); i++) {
    current_month.push({
      date: year + '-' + month + '-' + i + "号",
      day: weekList[new Date(date.setDate(i)).getDay()],//获取对应日期的星期
    });
  }
return weekList 

你可能感兴趣的:(uniapp,javascript,开发语言)