0

I've written a code, it works correctly but when pushing the variable inside an array, all the values inside that array are replaced by the new one.

var times = [];
var today = new Date();
var presentTime = today;
times.push(presentTime);
for(i=0;i<16;i++) {
    var thisTime = times[i];
    thisTime.setMinutes(thisTime.getMinutes()+30);
    thisTime.setHours(thisTime.getHours()+1);
    times.push(thisTime);
}

How to get an array of time with 1 & half hour increment??

0 Answers0