Posted By

pythox on 11/12/09


Tagged

regex time validation


Versions (?)

Validate Time


 / Published in: PHP
 

  1. /**
  2.  * Validates Time in 24 hour format (e.g. 20:32).
  3.  *
  4.  * @param string $time Name of submitted value to be checked.
  5.  */
  6. public function isTime($time)
  7. {
  8. return preg_match("#([0-1]{1}[0-9]{1}|[2]{1}[0-3]{1}):[0-5]{1}[0-9]{1}#", $time);
  9. }

Report this snippet  

You need to login to post a comment.