问题描述:

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 strDate = '2013-02-11'.split('-'),
        nrAddDays = 35,
        date = new Date(parseInt(strDate[0]), parseInt(strDate[1])-1, parseInt(strDate[2]));

    /* Add nr of days*/
    date.setDate(date.getDate() + nrAddDays);

    alert(date.toString());

I hope help you.

相关阅读:
Top