The question is simple, how can I add days to a date in YYYY-MM-DD format?
For example, increment a date given in this format: "2013-02-11" to "2013-02-12"?
The question is simple, how can I add days to a date in YYYY-MM-DD format?
For example, increment a date given in this format: "2013-02-11" to "2013-02-12"?
date = new Date('2013-02-11');
next_date = new Date(date.setDate(date.getDate() + 1));
here's a demo http://jsfiddle.net/MEptb/
Hope below code will helpful to you
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*24*60*60*1000);
}
var myDate = new Date('2013-02-11');
var newDate = addDays(myDate,5);
Something like this :
var date = new Date('2013-02-11');
/* Add nr of days*/
date.setDate(date.getDate() + 1);
alert(date.toString());
I hope it helps.
Below function is to Add number of days to today's Date It returns the Incremented Date in YYYY-MM-DD format @param noofDays - Specify number of days to increment. 365, for 1 year.
function addDaysToCurrentDate(noofDays){
date = new Date();
next_date = new Date(date.setDate(date.getDate() + noofDays));
var IncrementedDate = next_date.toISOString().slice(0, 10);
console.log("Incremented Date " +IncrementedDate );
return IncrementedDate;
}