[-] CORE: Fix regex for isDate and isDateFormat (0000-00-00 00:00:00 is now allowed)

This commit is contained in:
vSchoener
2011-10-19 15:22:11 +00:00
parent 30b74705e7
commit 3813a99bcc
+2 -2
View File
@@ -428,7 +428,7 @@ class ValidateCore
*/
public static function isDateFormat($date)
{
return (bool)preg_match('/^([0-9]{4})-((0?[0-9])|(1[0-2]))-((0?[1-9])|([0-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date);
return (bool)preg_match('/^([0-9]{4})-((0?[0-9])|(1[0-2]))-((0?[0-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date);
}
/**
@@ -439,7 +439,7 @@ class ValidateCore
*/
public static function isDate($date)
{
if (!preg_match('/^([0-9]{4})-((0?[1-9])|(1[0-2]))-((0?[1-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $matches))
if (!preg_match('/^([0-9]{4})-((0?[0-9])|(1[0-2]))-((0?[0-9])|([1-2][0-9])|(3[01]))( [0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $date, $matches))
return false;
return checkdate((int)$matches[2], (int)$matches[5], (int)$matches[0]);
}