/*返回date所在日期的当周及下周日期数组
*返回值'yyyy-mm-dd
*/
function getTwoWeeks(date) {
var curMonDayDate;
var curWeek = date.getDay();//获取当前是周几,周日为0
if (curWeek == 0) {
curWeek = 7;
}
var stDay = 1 - curWeek;//周一和当前差多少天,得出为非正数
curMonDayDate = addDate(date, stDay);//获取当前周的周一日期
var arrDate = [];
for (var i = 0; i < 14; i++) {
arrDate.push(addDate(new Date(curMonDayDate), i));
}
return arrDate;
}
//增加天数
function addDate(date, days) {
var d = new Date(date);
d.setDate(d.getDate() + days);
var m = d.getMonth() + 1;
return d.getFullYear() + '-' + m + '-' + d.getDate();
}
*返回值'yyyy-mm-dd
*/
function getTwoWeeks(date) {
var curMonDayDate;
var curWeek = date.getDay();//获取当前是周几,周日为0
if (curWeek == 0) {
curWeek = 7;
}
var stDay = 1 - curWeek;//周一和当前差多少天,得出为非正数
curMonDayDate = addDate(date, stDay);//获取当前周的周一日期
var arrDate = [];
for (var i = 0; i < 14; i++) {
arrDate.push(addDate(new Date(curMonDayDate), i));
}
return arrDate;
}
//增加天数
function addDate(date, days) {
var d = new Date(date);
d.setDate(d.getDate() + days);
var m = d.getMonth() + 1;
return d.getFullYear() + '-' + m + '-' + d.getDate();
}