Skip to content

Instantly share code, notes, and snippets.

@boilemmashem
Last active December 22, 2023 11:10
Show Gist options
  • Save boilemmashem/defbe6e36c660ab930305883cbf7420b to your computer and use it in GitHub Desktop.
Save boilemmashem/defbe6e36c660ab930305883cbf7420b to your computer and use it in GitHub Desktop.
Add days to date
/**
* Add days to given Date
* @param {Date}
* @param {number}
* @returns {Date}
*
* @example
* addDaysToDate(new Date(), 7) // date for 7 days from now
*/
export const addDaysToDate = (date: Date, days: number): Date => {
const addedDays: number = date.setDate(date.getDate() + days);
return new Date(addedDays);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment