title: Javascript - Convert ####-##-## to Epoch time
body: <p>Is there a way to take a date object from a HTML object in the format of <code>####-##-##</code> and convert it to epoch time. For example, the user inputs the value of August 12, 2012 which shows as 2012-08-12 when I print out the .val() of it, and I need to get this in Epoch time.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Code to date:</p>
  
  <pre><code>if (hvStartDate == "") {
      hvStartDate = "start"
  } 
  else {
      console.log($("#hv-start-date").val()); // =&gt; 2012-08-20
      hvStartDate = new Date($("#hv-start-date").val()).getTime(); // =&gt; NaN
  }
  if (hvEndDate == "") {
      hvEndDate = "end"
  } 
  else {
      hvEndDate = new Date($("#hv-end-date").val()).getTime(); // =&gt; NaN
  }
  
  var myTmp = new Date("2012-08-20");
  console.log(myTmp.getTime()); // =&gt; NaN
  </code></pre>