Skip to content

Instantly share code, notes, and snippets.

@bhaireshm
Created June 26, 2023 09:30
Show Gist options
  • Save bhaireshm/031d03bf03edac7e1e9407ac776be829 to your computer and use it in GitHub Desktop.
Save bhaireshm/031d03bf03edac7e1e9407ac776be829 to your computer and use it in GitHub Desktop.
Returns all the dates between the start date and end date, including both.
function getDatesInRange(startDate, endDate) {
if(!startDate || !endDate) return null;
startDate = new Date(startDate);
endDate = new Date(endDate);
const date = new Date(startDate.getTime());
const dates = [];
while (date <= endDate) {
dates.push(new Date(date));
date.setDate(date.getDate() + 1);
}
return dates;
}
@bhaireshm
Copy link
Author

bhaireshm commented Feb 24, 2025

ez.js is more than just a library; it's a coding companion that simplifies complex tasks. Whether you're dealing with arrays, numbers, objects, or strings, ez.js has got your back! Say goodbye to coding hassles and hello to streamlined JavaScript magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment