title: Parsing date strings using google apps script
body: <p>I'm new to google apps script, and I'm having trouble parsing date strings from a UiApp form. In this instance, I'm writing a script to allow the user to filter a timestamped spreadsheet within a specified date range. </p>
  
  <p>My problem is that the code below returns an invalid date object when passed a date string (from a text box named <code>dateFromField</code>) in the conventional javascript format <code>YYYY,M,D</code> (i.e. <code>2012,1,2</code> for Feb 2, 2012):</p>
  
  <pre><code>function dateFilter(e) {
    var fromDate = new Date(e.parameter.dateFromField);
  } 
  </code></pre>
  
  <p>I've checked that the <code>e.parameter.dateFromField</code> correctly returns the given string (<code>Logger.log(e.parameter.dateFromField);</code> returns <code>2012,1,2</code>), and that its type is string (rather than object).</p>
  
  <p>However, if I type the date string into the function directly, i.e.:</p>
  
  <pre><code>function dateFilter(e) {
    var fromDate = new Date(2012,1,2);
  } 
  </code></pre>
  
  <p>I get valid a date object. I don't understand the difference between these two examples - as far as I can tell they are equivalent; in both instances the string <code>2012,1,2</code> is being passed to the <code>new Date</code> function. I'm obviously missing something simple - can anyone tell me what?</p>