title: Javascript: How to generate monthly dates?
body: <p>I need to calculate monthly dates, that is, given a particular date, generate dates for the next 2 years for example. I came up with the following code:</p>
  
  <pre><code>var d = new Date( '2007-12-31' );
    d.setMonth( d.getMonth() + 1 );
    for (var i = 1; i&lt;24; i++){
      var newdate = d.getDate() + "-" + d.getMonth()+i + '-' + d.getFullYear()
      print(newdate);
    }
  </code></pre>
  
  <p>However, this is producing:</p>
  
  <pre><code>(...)
  31-06-2008  (ok)
  31-07-2008  (ok)
  31-08-2008  (ok)
  31-09-2008  (ok)
  31-010-2008 (error, 3 characters for month) 
  31-011-2008 (error, 3 characters for month)
  31-012-2008 (error, 3 characters for month)
  31-013-2008 (error, should be 31-01-2009)
  31-014-2008 (error, should be 28-02-2009)
  </code></pre>
  
  <p>Please, is there any way of producing monthly dates considering some months are 30 or 31 days and February is 28 or 29 depending on the years? Thanks!</p>