title: How do I convert a string to a date in Apps-Script
body: <p>I'm having some problems getting a date string (such as "17/08/2012") to a date so that it can be used to compare another date.</p>
  
  <p>I would like "17/08/2012" to produce the date "17/08/2012 00:00:00 GMT" so that it can be used correctly for comparison. I thought this would be the easiest part of what I'm trying to do, but apparently not. Please see my current code below.</p>
  
  <pre><code>function dateToString(dateString) {
    var dateArray = dateString.split("/");
    var year = dateArray[2];
    var month = dateArray[1];
    var day = dateArray[0];
    var date = new Date(year, month - 1, day);
  
    return date;
  }
  </code></pre>
  
  <p>This code currently produces "Fri Aug 17 16:00:00 PDT 2012" and I have absolutely no idea why it says 4pm. I have been trying loads of different ways of doing this for the past hour and still cannot seem to get it right. Any ideas how I can get it to convert correctly?</p>
  
  <p>As always any help is much appreciated.</p>