Reputation: 8582
I have the following code:
<?php
$dateString = '12.12.12';
$dateCheckArray['format'] = 'dd-mm-yyyy';
$validator = new Zend_Validate_Date($dateCheckArray);
if ($validator->isValid($dateString)) {
echo 'valid';
}
else {
echo 'invalid';
}
The code works ok for most formats, but for the one specified it fails when using a . date instead of a - date.
For example for the date specified before (12.12.12) the script will echo 'valid', even though it obviously doesn't fit the format.
Can anyone point out why this is happening?
Note: This is zend 1.
Upvotes: 2
Views: 630
Reputation: 4615
There is a bug in ZF-7583: Zend_Date::isDate accepts invalid dates. Thats why some dates are showing in correct. Its better to use a regex validation for it.
You can check this post for the regex Regex to validate date format dd/mm/yyyy
Upvotes: 1