title: Validate time format using preg_match
body: <p>I want to validate a time input (like 10:30 am, 02:30 pm) using <code>preg_match()</code></p>
  
  <p>I use this,</p>
  
  <pre><code> $pattern   =   "/([1-12]):([0-5])([0-9])( )(am|pm|AM|PM)/";
   if(preg_match($pattern,$time)){
     return true;
   }
  </code></pre>
  
  <p>But when i give an input like <code>10:30 pmxxxx</code> it will not validated.
  I dont know whether the method is correct or not. Help please.</p>