mercredi 25 avril 2018

PHP datetime check

I need to check the date using PHP for the pattern: dd.mm.yyyy hh:mm. So far i got my RegExp and the if statement. Everytime i fill it out correct or incorrect it gives me the alert message box. Can somebody help me out?

$uzorak = '/^([1-9]|([012][0-9])|(3[01]))\-([0]{0,1}[1-9]|1[012])\-\d\d\d\d\s([0-1]?[0-9]|2?[0-3]):([0-5]\d)$/';
$datum = $_GET["datum"];

if (!preg_match($uzorak, $datum)) {
    echo "<script>alert('Datum se ne preklapa s predloškom!');</script>";
}

Aucun commentaire:

Enregistrer un commentaire