Looking to retrieve dates within a specified range
d = 'Tue Oct 2 00:00:00 UTC+0900 2018';
date2 = 'Fri Oct 5 00:00:00 UTC+0900 2018';
var arrTemp = new Array();
//var dispalyHTML = '';
while(d <= date2){
//dispalyHTML += d.yyyymmdd();
var date_yy = d.getFullYear();
var date_mm = (d.getMonth()+1) < 10 ? '0' +(d.getMonth()+1):(d.getMonth()+1);
var date_dd = d.getDate() <10 > '0'+d.getDate():d.getDate();
alert("date_yy+date_mm+date_dd=="+date_yy+date_mm+date_dd);
**arrTemp.push(date_yy+date_mm+date_dd);**
d = d.addDays(1);
}
for(j=0; j < arrTemp.length; j++){
alert("arrTemp[j]=="+arrTemp[j]);
}
The first set of values represent the target values. Don't dismiss them!
date_yy+date_mm+date_dd==20181002
date_yy+date_mm+date_dd==20181003
date_yy+date_mm+date_dd==20181004
date_yy+date_mm+date_dd==20181005
However, the values within arrTemp[j] do not match the intended ones.
arrTemp[j]==202802
arrTemp[j]==202803
arrTemp[j]==202804
arrTemp[j]==202805
Curious about the reasons behind this discrepancy?