Calculate Date with start date and number of days with javascript - Javascript Date Operation

Javascript examples for Date Operation:Date Calculation

Description

Calculate Date with start date and number of days with javascript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//from w w  w  .  ja  v  a2s.  co  m
calculateDateFromDays = function(startDate, days) {
    var nextDate = new Date()
    nextDate.setDate(new Date(startDate).getDate() + days)
    return nextDate
};
console.log(calculateDateFromDays("10-28-2018", 4));
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials