Skip to content

Instantly share code, notes, and snippets.

@johanmynhardt
Created December 5, 2017 18:54
Show Gist options
  • Save johanmynhardt/e515bf366957ce251e6ae23f02921c68 to your computer and use it in GitHub Desktop.
Save johanmynhardt/e515bf366957ce251e6ae23f02921c68 to your computer and use it in GitHub Desktop.
Add number of days to given date.
/**
* 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