JSは現在の日付の3ヶ月の日付を取得し、週末を除く
3153 ワード
function GetDateTime() {
var dateNew = new Date();
var mydate = dateNew.toLocaleDateString(); //
var getDate = dateNew.getDate();//
var getYear = dateNew.getFullYear();//
var getMonth = parseInt(dateNew.getMonth() + 1);// 1 0 +1
var Newdate = new Date(getYear, getMonth, 0)
var daycount = Newdate.getDate();//
var k = 1
var data = []
for (i = getDate; i < daycount + 1; i++) {
var dateDay = new Date(getYear + '/' + getMonth + '/' + i);
var weekDay = dateDay.getDay();//
if (weekDay != 6 && weekDay != 0) {
data.push({date: "" + getYear + "-" + getMonth + "-" + i + ""})
}
if (i == daycount) {//
if (k < 4) {
getMonth = parseInt(dateNew.getMonth() + 1 + k);// 1 0 +1
Newdate = new Date(getYear, getMonth, 0)
daycount = Newdate.getDate();//
getDate = 1;
k = k + 1
i = 0;
}
}
}
return data
};