Last active
December 11, 2019 15:54
-
-
Save moshiurse/29f15df3196b871023a11877dfb5b359 to your computer and use it in GitHub Desktop.
add days to date in javascript
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
Date.prototype.addDays = function (days) { | |
return new Date(this.valueOf() + days * 864e5); | |
} | |
var date = new Date("2019-10-01"); | |
date.addDays(50); | |
// Or | |
var someDate = new Date("2019-10-01"); | |
var numberOfDaysToAdd = 50; | |
someDate.setDate(someDate.getDate() + numberOfDaysToAdd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment