js 当前日期后7天

时间:2021-02-12 18:06:50

    var myDate = new Date(); //获取今天日期
         
            var dateArray = [];
            var dateTemp;
            var flag = 1;
            for (var i = 0; i < 7; i++) {
                dateTemp = (myDate.getMonth() + 1) + "-" + myDate.getDate();
                dateArray.push(dateTemp);
                $("#bzrq").append("<option>" + dateTemp.replace('-','月')+'日' + "</option>");
                myDate.setDate(myDate.getDate() + flag);
            }