title: How to format a date pulled from a form field with javascript
body: <p>I have a date picker that generates a date like 6/30/2012 in a form field. </p>
  
  <p>I need to convert this date to 2012-06-30 for mysql. I can get it close with the following.</p>
  
  <pre><code>var datePart=document.getElementById('formdate').value.split(/[^0-9]+/);
  </code></pre>
  
  <p>and then use to generate the date. </p>
  
  <pre><code>datePart2[2] + "-" + datePart2[1] + "-" + datePart2[0]
  </code></pre>
  
  <p>The problem is it gived me the date 2012-6-30 instead of 2012-06-30. </p>
  
  <p>Is there an easier way to do this? Or a way to use my current method and ad a zero to the front of a digit if it is a single digit?</p>