javascript - alternate dates between 2 dates Jquery -


how find alternate days between 2 dates. here jquery code finds total number of hours between dates.

var strt_date="2016-02-03";                 var end_date = "2016-02-08";                 strt_date = new date(strt_date);                 end_date = new date(end_date);                  var hours=math.abs(strt_date - end_date) / 36e5;                 console.log(hours); 

how find alternate dates between these 2 dates

update:the output 2016-02-03 2016-02-05 2016-02-07 alternate dates between 2 dates starting selected date

var start   = new date("2016-02-03"); var end     = new date("2016-02-08"); var between = []; var mil     = 86400000 //24h var init    = 0; (var i=start.gettime(); i<end.gettime();i=i+mil) {     if(init%2==0) between.push(new date(i));     //if(init%2==0) between.push(inddate.getfullyear()+"-"+(inddate.getmonth()+1)+"-"+inddate.getdate());     //above condition returns dates in 'yyyy-mm-dd' format     init++;  } console.log(between); 

output

wed feb 03 2016 05:30:00 gmt+0530 (india standard time) fri feb 05 2016 05:30:00 gmt+0530 (india standard time) sun feb 07 2016 05:30:00 gmt+0530 (india standard time) //this date format can changed required one, while push content array 

check above code, above things go normal here, added for loop in order achieve range in array, add condition under looping statement alternate number of days.

thanks & regards


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -