Computer >> Computer tutorials >  >> Programming >> Javascript

How to add number of days to JavaScript Date?


To add the number of days, use the Date() function to display the current date and then add two days

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <script>
         var date, incDate;
         date = new Date();
         document.write(date);

         var incDate = new Date(new Date().getTime()+(2*24*60*60*1000));
         document.write("<br>"+incDate);
      </script>
   </body>
</html>