title: Last 12 months in Javascript
body: <p>I got an Kendo ui Chart like <a href="http://demos.kendoui.com/dataviz/area-charts/grouped-data.html" rel="noreferrer">this</a> one and have to show the last 12 months of todays date on the axis. <br />
  I found <a href="http://dansnetwork.com/javascript-date-object-adding-and-subtracting-months/" rel="noreferrer">this</a> to extend the date object to get the previous month. The problem seems to be when I got an Date like "2013/05/31" and the previous months got no 31st day.</p>
  
  <pre><code>Date.prototype.toPrevMonth = function (num) {
      var thisMonth = this.getMonth();
      this.setMonth(thisMonth-1);
      if(this.getMonth() != thisMonth-1 &amp;&amp; (this.getMonth() != 11 || (thisMonth == 11 &amp;&amp;      this.getDate() == 1)))
      this.setDate(0);
  }
  
  
  new Date().toPrevMonth(11),
  new Date().toPrevMonth(10),
  new Date().toPrevMonth(9),
  new Date().toPrevMonth(8),
  new Date().toPrevMonth(7),
  new Date().toPrevMonth(6),
  new Date().toPrevMonth(5),
  new Date().toPrevMonth(4),
  new Date().toPrevMonth(3),
  new Date().toPrevMonth(2),
  new Date().toPrevMonth(1),
  new Date().toPrevMonth(0)
  </code></pre>
  
  <p>Can anyone help me out with the if state?<br /> The function is build to show only the previous month, but I need the last 12 previous months. </p>
  
  <p>Or is there a much easier solution? :-)</p>
  
  <p>Thanks for all!</p>