巨长的链。。。
var lastMonth = [];
for(var i = 0;i<30;i++){
lastMonth.unshift(new Date(new Date()
.setDate(new Date().getDate()-i))
.toLocaleString().substring(0,10))
}
结果如下:
[“2018/3/12”, “2018/3/13”, “2018/3/14”, “2018/3/15”, “2018/3/16”, “2018/3/17”, “2018/3/18”, “2018/3/19”, “2018/3/20”, “2018/3/21”, “2018/3/22”, “2018/3/23”, “2018/3/24”, “2018/3/25”, “2018/3/26”, “2018/3/27”, “2018/3/28”, “2018/3/29”, “2018/3/30”, “2018/3/31”, "2018/4/1 ", "2018/4/2 ", "2018/4/3 ", "2018/4/4 ", "2018/4/5 ", "2018/4/6 ", "2018/4/7 ", "2018/4/8 ", "2018/4/9 ", “2018/4/10”]