Skip to content

Get all dates within range in react js

function (startDate, endDate, addFn, interval) {

 addFn = addFn || Date.prototype.addDays;
 interval = interval || 1;

 var dates = [];
 var current = new Date(startDate);

 while (current <= endDate) {
  dates.push(new Date(current));
  current = addFn.call(current, interval);
 }

 return dates;

}
See also  How to get client's IP address using JavaScript?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.