<!doctype html> <html> <head> <meta charset="utf-8"> <title>获取当前时间到30天之后的日期区间</title> </head> <body> <script> var startDate = new Date(); var endDate = new Date(); endDate.setDate(startDate.getDate() + 30); var dataArr = []; var weeks = ['日', '一', '二', '三', '四', '五', '六']; while((endDate.getTime() - startDate.getTime()) >= 0) { var month = (startDate.getMonth() + 1).toString().length == 1 ? "0" + (startDate.getMonth() + 1).toString() : (startDate.getMonth() + 1); var day = startDate.getDate().toString().length == 1 ? "0" + startDate.getDate() : startDate.getDate(); var week = weeks[startDate.getDay()]; dataArr.push(month + "月" + day + '日(周' + week + ')'); startDate.setDate(startDate.getDate() + 1); } dataArr[0] = '今天' + dataArr[0].slice(6, 10); dataArr[1] = '明天' + dataArr[1].slice(6, 10); dataArr[2] = '后天' + dataArr[2].slice(6, 10); console.log(dataArr); </script> </body> </html>