Add to current date with javascript and have months roll over - Javascript jQuery

Javascript examples for jQuery:Date

Description

Add to current date with javascript and have months roll over

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.js"></script> 
  <script type="text/javascript">
    $(function(){/*w w w .  j ava2s.  c  o  m*/
var today = new Date();
var addDays = 2;

var addMs = addDays * 24 * 60 * 60 * 1000;

var newDate = new Date();
newDate.setTime(today.getTime() + addMs);
console.log(newDate);
    });

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

Related Tutorials