I am using zend framework 1.12.0 and i have a value fetching from database to be validated. That is if its a date value then i have to change the format into YYYY-MM-DD to MM/DD/YYYY.Else i keep the value as ''.I am using the following code
$validator = new Zend_Validate_Date();
if(trim($value)=='0000-00-00' || $validator->isValid(trim($value))){
if($validator->isValid(trim($value))){
$utilObj = new Utilityclass();
$arrayReturn[$key] = $utilObj->getDateMdy($value,"/");
}
else{
$arrayReturn[$key] = '';
}
}
My problem is that the date value may be in YYYY-MM-DD or YYYY-MM-DD H:i:s format.So when its YYYY-MM-DD i am getting the correct output.If its YYYY-MM-DD H:i:s its not converting the format.So how to check a value is a valid date if its in YYYY-MM-DD or YYYY-MM-DD H:i:s format using zend.