Incrementing a date in JavaScript

后端 未结 17 2355
余生分开走
余生分开走 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 06:03

    Incrementing date's year with vanilla js:

    start_date_value = "01/01/2019"
    var next_year = new Date(start_date_value);
    next_year.setYear(next_year.getYear() + 1);
    console.log(next_year.getYear()); //=> 2020
    

    Just in case someone wants to increment other value than the date (day)

提交回复
热议问题