Javascript Data Type How to - Find next 30 days








Question

We would like to know how to find next 30 days.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!-- w  ww  .j  a  va2s  .  co  m-->
    var today = new Date();
    var year = today.getFullYear();
    var month = today.getMonth();
    var date = today.getDate();
    for(var i=0; i<30; i++){
          var day=new Date(year, month - 1, date + i);
          document.writeln(day);
          document.writeln('<br/>');
    }
}
</script>
</head>
<body>
  <div></div>
</body>
</html>

The code above is rendered as follows: