Skip to content

Instantly share code, notes, and snippets.

@ginotria
Created October 10, 2012 14:51
Show Gist options
  • Save ginotria/3866110 to your computer and use it in GitHub Desktop.
Save ginotria/3866110 to your computer and use it in GitHub Desktop.
Javascript: Get Range of Dates in Array
Date.prototype.addDays = function(days) {
var dat = new Date(this.valueOf());
dat.setDate(dat.getDate() + days);
return dat;
};
function getDates(startDate, stopDate) {
var dateArray = [];
var currentDate = startDate;
while (currentDate <= stopDate) {
dateArray.push(self.formatDate(currentDate));
currentDate = currentDate.addDays(1);
}
return dateArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment