Created
January 7, 2017 15:00
-
-
Save claudiohilario/457373bbf22cb6502be9a657c94a102a to your computer and use it in GitHub Desktop.
Funções de Validação
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Permite validar a hora | |
* @param type $hora Hora no formato H:m | |
* @return boolean | |
*/ | |
function validarHora($hora) { | |
if (preg_match('/^[0-9]{2}:[0-9]{2}$/', $hora)) { | |
$horas = substr($hora, 0, 2); | |
$minutos = substr($hora, 3, 2); | |
if (($horas > "23") OR ( $minutos > "59")) { | |
return false; | |
} | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment