Last active
December 22, 2023 11:10
-
-
Save boilemmashem/defbe6e36c660ab930305883cbf7420b to your computer and use it in GitHub Desktop.
Add days to date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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