Contactos









Ing. en Computación Jaime José Suárez Gimenez
Correo: ingjjsg@gmail.com
Barquisimeto Estado Lara Venezuela



miércoles, 31 de octubre de 2012

Validar  Formato Hora


public static function ValidarHora($hora)
  {
    $auxhora = split(":",$hora);
    $separadorhora=substr($hora,2,1);
    $formatohora=substr($hora,5);
    if(count($auxhora)>1 && strlen($hora)==7 && $separadorhora==':')
        if(strtoupper($formatohora)=="AM" || strtoupper($formatohora)=="PM")
        {
            $phoras=$auxhora[0];
            $pmin=substr($auxhora[1],0,2);
            if(is_numeric($phoras))
                if(intval($phoras)>=1 && intval($phoras)<=12)
                    return true;
                else
                    return false;
            else
                return false;
            if(is_numeric($pmin))
                if(intval($pmin)>=0 && intval($pmin)<=59)
                    return true;
                else
                    return false;
            else
                return false;
        }else
            return false;
     else
        return false;

}

No hay comentarios: