public static function isValidHour($time)
    {
        $result = preg_match('/^([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2}))?$/', $time, $regs);
        if ($result) {
            $hour = $regs[1];
            $minutes = $regs[2];
            $result = ($hour >= 0 && $hour < 24) && ($minutes >= 0 && $minutes < 60);
            if ($result && isset($regs[3])) {
                $seconds = $regs[3];
                $result = $seconds >= 0 && $seconds < 60;
            }
        }
        return $result;
    }