I am trying to figure out how to increment a date by adding days and then expanding that date over a specific time period. I have encountered an issue with getting the date to increment correctly without using a plugin. Any suggestions? One key problem is when the dates extend into a new year, it always defaults to the current year due to how I initialized the date. If my explanation is unclear, please feel free to ask questions for clarification.
var last, packEndDate, packStartDate;
while (i < frequencyValue) {
packStartDate = new Date();
packEndDate = new Date();
debugger;
if (isWeek) {
packStartDate.setDate(startDate.getDate() + (7 * i));
packEndDate.setDate(packStartDate.getDate() + 7);
} else {
packStartDate.setDate(startDate.getDate() + (30 * i));
packEndDate.setDate(packStartDate.getDate() + 30);
}
last = frequencyValue - 1;
if (i === last) {
packEndDate = endDate;
}
}
i++;
}