strip colons from the $time, $to and $from strings, convert to int and then use the following condition to check if the time is between from and to. Example is in php, but shouldn't matter.
if(($to < $from && ($time >= $from || $time <= $to)) ||
($time >= $from && $time <= $to)) {
return true;
}