function getAll(value1, value2) {
var arr=[];
var getDate = function(str) {
var tempDate = new Date();
var list = str.split("-");
tempDate.setFullYear(list[0]);
tempDate.setMonth(list[1] - 1);
tempDate.setDate(list[2]);
return tempDate;
}
var date1 = getDate(value1);
var date2 = getDate(value2);
if (date1 > date2) {
var tempDate = date1;
date1 = date2;
date2 = tempDate;
}
date1.setDate(date1.getDate());
var dateArr = [];
var i = 0;
while (!(date1.getFullYear() == date2.getFullYear()
&& date1.getMonth() == date2.getMonth() && date1.getDate() == date2
.getDate()))
{
var dayStr =date1.getDate().toString();
if(dayStr.length ==1){
dayStr="0"+dayStr;
}
dateArr[i] = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-"
+ dayStr;
date1.setDate(date1.getDate() + 1);
i++;
}
arr=dateArr;
arr.push(value2)
return arr;
}
console.log(getAll('2017-12-27','2018-1-2'))//["2017-12-27", "2017-12-28", "2017-12-29", "2017-12-30", "2017-12-31", "2018-1-01", "2018-1-2"]