title: Google Apps Script get current month from Date()
body: <p>I'm currently working on a function to generate data according to a start and an end date.</p>
  
  <p>While I was testing my functions I've realized some wrong calculated values.</p>
  
  <p>Long story short the <code>getMonth()</code> method for <code>Date</code> objects is returning a unexpected value.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var date = new Date();
  console.log(date.getMonth());
  var date2 = new Date(2014, 1, 1);
  console.log(date2);</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can someone explain to me the reason why to start a month at 0, even if it's not possible to create a right <code>Date</code> object using that index.</p>
  
  <p>Even though <code>date2</code> my second example is from the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Parameters" rel="nofollow noreferrer">official docu</a> of JS and is returning a unexpected value according to the example giving in the "Parameters" section. </p>