Skip to content

Instantly share code, notes, and snippets.

@NKid
Created April 24, 2013 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NKid/cd6949fa7835a48e1ce6 to your computer and use it in GitHub Desktop.
Save NKid/cd6949fa7835a48e1ce6 to your computer and use it in GitHub Desktop.
Add Days
//Method 1
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
console.log(today);
console.log(tomorrow);
//Method 2
var today = new Date();
var tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
console.log(today);
console.log(tomorrow);
//Method 3
Date.prototype.addDays = function(days) {
var d = new Date(this.valueOf());
d.setDate(d.getDate() + days);
return d;
}
var today = new Date();
console.log(today.addDays(1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment