diff options
author | Lance Vincent <lancevincent@gmail.com> | 2015-01-26 14:18:25 +0100 |
---|---|---|
committer | Lance Vincent <lancevincent@gmail.com> | 2015-01-26 14:18:25 +0100 |
commit | e700c31255ca2cf1a6c38bdf0db962cc48304e55 (patch) | |
tree | 3c3fdfab5107ad9c9f5824e5bde679a5274a35f0 /system/libraries | |
parent | 8e72ecf6182a88cc7224f94a979085a06fea03d4 (diff) |
Form Validation - Date Method
Value should be a valid date
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Form_validation.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index e98c87f81..3e8204eee 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1475,6 +1475,31 @@ class CI_Form_validation { // -------------------------------------------------------------------- /** + * Value should be a valid date + * + * @param string + * @return bool + */ + public function date($date) + { + if (strtotime($date) === FALSE) + { + return FALSE; + } + + if ($date instanceof DateTime) + { + return TRUE; + } + + $date = date_parse($date); + + return checkdate($date['month'], $date['day'], $date['year']); + } + + // -------------------------------------------------------------------- + + /** * Is a Natural number (0,1,2,3, etc.) * * @param string |