by @kodeazy

javascript How to add n number of days to current date in javascript?

Home » javascript » javascript How to add n number of days to current date in javascript?
  • In this blog we will discuss on how to add n number of days to current date object using javascript.
  • To add the n number of hours to date object we follow below syntax.

    var n=1;
    date.setDate(date.getDate() + n);
  • Below is an example program of setting hour to date object.

    var date = new Date();// Try edit me
    var n=1;
    date.setDate(date.getDate() + n);
    console.log(date);

    Output

    Thu Sep 08 2022 07:25:30 GMT+0530 (India Standard Time)