Created
December 5, 2017 18:54
-
-
Save johanmynhardt/e515bf366957ce251e6ae23f02921c68 to your computer and use it in GitHub Desktop.
Add number of days to given 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 the specified number of days to the date provided. | |
*/ | |
var addDays = (date, days) => { | |
var newDate = new Date(date); | |
newDate.setDate(newDate.getDate() + days); | |
return newDate; | |
} | |
// example: | |
var now = new Date(); | |
var nextWeek = addDays(now, 7); | |
console.info('now: ', now); | |
console.info('next week: ', nextWeek); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment