Date validation with Zend

1

How to validate a date using Zend? When the user signs up, I need to validate the anniversary date and see if it is over 18.

I receive 3 fields - day, month and year and would like to validate the registration only for those over 18

I found this code, but I do not know how to enter the +18 parameter

$validator = new Zend_Validate_Date(array(
    'format' => 'dd-mm-yyyy',
    'locale' => $yourLocale
);

Thank you

    
asked by anonymous 23.07.2014 / 11:40

1 answer

2

Dude, when the person informs the birthday date you can pick up if the date he reported is earlier than the date to be 18.

For example: If the guy said he was born in 1998-07-07, that date is later than the minimum to be 18 years old (That would be in the year 1996). To make these checks if it is before or after the date you can use the methods below:

$dateOne = new Zend_Date(time());
$dateTwo = new Zend_Date(time());

 // verifica se a segunda data é posteRior a segunda 
if ($dateOne->isLater($dateTwo)) {
 // BLABLA
}
  // verifica se a primeira data é antes da segunda
if ($dateOne->isEarlier($dateTwo)) {
 // BLABLA
}
    
23.07.2014 / 13:59