(Just wondering about this answer being a duplicate? I see the other answers are NOT asking for the result in Milliseconds???)
Was simply trying to fill in dates between start and end date:
<div id="my_div">
</div>
<script>
var START_DATE_MILLISECONDS = new Date("03/12/2017").getTime();
var END_DATE_MILLISECONDS = new Date("03/17/2017").getTime();
var HRS_24_Converted_To_Millisecs = 86400000; //24h
for(var i=START_DATE_MILLISECONDS; i<=END_DATE_MILLISECONDS; i+=HRS_24_Converted_To_Millisecs){
var i_converted = new Date(i);
document.getElementById('my_div').innerHTML += "~ i ~ ="+i+" -> "+i_converted+"<BR>";
var END_DATE_MILLISECONDS = new Date(END_DATE_MILLISECONDS);
document.getElementById('my_div').innerHTML += "~ END_DATE_MILLISECONDS ~ ="+END_DATE_MILLISECONDS+" ->"+END_DATE_MILLISECONDS+" <br>";
}
document.getElementById('my_div').innerHTML += "<BR><BR>";
var i_converted = new Date(i);
document.getElementById('my_div').innerHTML +=(" \n\n ______________________________ <BR>EXIT LIOOP IAND i = "+i+" -><BR><span style='color:red;'>"+i_converted+"</span><BR>__________________________________________ <BR>");
</script>
https://jsfiddle.net/kdfiddle/dfLh04qc/
The dates should loop through and include the 17th - but it is skipped because the for loop reaches a value greater - by one hour - then the last day 17th.
This only happens if the 13th day of March (spooky 0_o) is included in the calculation. Anything before - or after seems to work properly.
I suspect the UTC is the issue - but am not certain what to do about it. Is the ++ 86400000 a good idea for incrementing dates? Something that works more... "fool" proof?