below is my code for checking the variable is either time or not
function isTime($time) {
if (preg_match("/^([1-2][0-3]|[01]?[1-9]):([0-5]?[0-9]):([0-5]?[0-9])$/", $time))
{
return true;
echo "<script>alert('is a time');</script>";
}
else {
echo "<script>alert('not a time');</script>";
return false;
}
}
and this is expression fails when value like this $time=00:08:33
, and working fine with time like $time=01:08:33
, please modify this expression