Add days to JavaScript Date -


how add days current date using javascript. javascript have built in function .net's addday?

you can create 1 with:-

date.prototype.adddays = function(days) {    var dat = new date(this.valueof());    dat.setdate(dat.getdate() + days);    return dat;  }    var dat = new date();    alert(dat.adddays(5))

this take care of automatically incrementing month if necessary. example:

8/31 + 1 day become 9/1.

the problem using setdate directly it's mutator , sort of thing best avoided. ecma saw fit treat date mutable class rather immutable structure.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -