-
-
Save NKid/cd6949fa7835a48e1ce6 to your computer and use it in GitHub Desktop.
Add Days
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
//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