title: Safari JS cannot parse YYYY-MM-DD date format?
body: <p>In a project I am working on, I need to validate a date entered into an <code>&lt;input type="date"&gt;</code></p>
  
  <p>With Safari 4/5 (on Mac OSX) the Javascript fails to parse dates of the format <code>YYYY-MM-DD</code>, returning <code>NaN</code> instead of the expected epoch timestamp.</p>
  
  <p>I am using the following technique to validate the field just before the form is submitted:</p>
  
  <pre><code>//value = '2010-06-21'
  var stamp = Date.parse(value);
  if (isNaN(stamp)) {
      //notify user
  } else {
      value = new Date(stamp).format_mysql();
  }
  </code></pre>
  
  <p>Where <code>format_mysql()</code> is a prototype function that formats the date (correctly) into MySQL Date-Time format (YYYY-MM-DD).</p>
  
  <p>Replacing the <code>-</code>'s with <code>/</code>'s (YYYY/MM/DD) yields a "correct" timestamp.</p>
  
  <p>I should note that the field should accept any date format, not just YYYY-MM-DD, and that though I would like to, I cannot use libraries like Date.js</p>
  
  <p><strong>How can I fix this, or is there a better way to parse/validate a date?</strong></p>