Skip to content

Instantly share code, notes, and snippets.

@allenfernzz
Created February 10, 2015 19:26
Show Gist options
  • Select an option

  • Save allenfernzz/a28cc9d14770980f0747 to your computer and use it in GitHub Desktop.

Select an option

Save allenfernzz/a28cc9d14770980f0747 to your computer and use it in GitHub Desktop.
Time Parser
<?php
//An Regular Expression Parser for Time followed by a text
function check_for_time()
{
//we are following 24 hour clock pattern
$string = "02:00 am I am still working";
$pattern = "/([01]?[0-9]|2[0-3]):[0-5][0-9]/";
if (preg_match($pattern, $string, $matches)) {
echo "<br/>Match was found <br />";
echo $matches[0];
}
}
check_for_time();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment