title: How to parse a time into a Date object from user input in JavaScript?
body: <p>I am working on a form widget for users to enter a time of day into a text input (for a calendar application). Using JavaScript (we are using jQuery FWIW), I want to find the best way to parse the text that the user enters into a JavaScript <code>Date()</code> object so I can easily perform comparisons and other things on it.</p>
  
  <p>I tried the <code>parse()</code> method and it is a little too picky for my needs. I would expect it to be able to successfully parse the following example input times (in addition to other logically similar time formats) as the same <code>Date()</code> object:</p>
  
  <ul>
  <li>1:00 pm</li>
  <li>1:00 p.m.</li>
  <li>1:00 p</li>
  <li>1:00pm</li>
  <li>1:00p.m.</li>
  <li>1:00p</li>
  <li>1 pm</li>
  <li>1 p.m.</li>
  <li>1 p</li>
  <li>1pm</li>
  <li>1p.m.</li>
  <li>1p</li>
  <li>13:00</li>
  <li>13</li>
  </ul>
  
  <p>I am thinking that I might use regular expressions to split up the input and extract the information I want to use to create my <code>Date()</code> object. What is the best way to do this?</p>