its possible to use regular expressions to do this but if you want to make sure the time is a real time and not just fitting the format, its somewhat easier to use a function like that below.
this will check to make sure the time is one that is allowed on a clock, and you can pass a 1 to the second optional parameter to validate a 24 hour time.
<?php
function is_time($time, $_24hour = FALSE)
{
if ($_24hour) {
$min = 0; $max = 23;
} else {
$min = 1; $max = 12;
}
$parts = explode(':', $time);
$valid = TRUE;
if (sizeof($parts) != 3) {
$valid = FALSE;
} else {
if ($parts[0] < $min || $parts[0] > $max) {
$valid = FALSE;
} else if ($parts[1] < 0 || $parts[1] > 59) {
$valid = FALSE;
} else if ($parts[2] < 0 || $parts[2] > 59) {
$valid = FALSE;
}
}
return $valid;
}
echo is_time("09:13:59");
?>