note 78362 modified in function.checkdate by danbrown

From: Date: Sun, 20 Jul 2008 02:29:56 +0000
Subject: note 78362 modified in function.checkdate by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141964@lists.php.net to get a copy of this message
here's a cool function to validate a mysql datetime: <?php function isValidDateTime($dateTime) { if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) { if (checkdate($matches[2], $matches[3], $matches[1])) { return true; } } return false; } ?> --was-- here's a cool function to validate a mysql datetime: function isValidDateTime($dateTime) { if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) { if (checkdate($matches[2], $matches[3], $matches[1])) { return true; } } return false; } http://php.net/manual/en/function.checkdate.php

« previous php.notes (#141964) next »