Incrementing a date in JavaScript

后端 未结 17 2151
余生分开走
余生分开走 2020-11-22 05:15

I need to increment a date value by one day in JavaScript.

For example, I have a date value 2010-09-11 and I need to store the date of the next day in a JavaScript v

17条回答
  •  粉色の甜心
    2020-11-22 05:44

    Getting the next 5 days:

    var date = new Date(),
    d = date.getDate(),
    m = date.getMonth(),
    y = date.getFullYear();
    
    
    for(i=0; i < 5; i++){
    var curdate = new Date(y, m, d+i)
    console.log(curdate)
    }
    

提交回复
热议问题