title: Google Apps Script: parsing strings as Date objects
body: <p>All,</p>
  
  <p>Consider the following JavaScript snippet, which takes a stringified date and creates a new <code>Date</code> object:</p>
  
  <pre class="lang-js prettyprint-override"><code>var str = '2016-02-01';
  var d = new Date(str);
  console.log(d);
  </code></pre>
  
  <p>Running the above returns, for example, <code>Mon Feb 01 2016 00:00:00 GMT+0000 (GMT Standard Time)</code>.</p>
  
  <p>However, running the equivalent code as a Google Apps Script function does not yield the same result:</p>
  
  <pre class="lang-js prettyprint-override"><code>function strToDateTest() {
     var str = '2016-02-01';
     var d = new Date(str);
     Logger.log(d);
  }
  </code></pre>
  
  <p>In this case, the output is <code>Thu Jan 01 01:00:00 GMT+01:00 1970</code>.</p>
  
  <p>I assume, given the differing log outputs, Google Apps Script is using its own implementation of <code>Date</code> and not <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date" rel="nofollow">the native JavaScript object</a>.</p>
  
  <p>Could someone shed some light on this, and advise how best to parse date values in Google Apps Script?</p>