I tried using this in my model class but it doesnt work
array(‘empdob’, ‘ext.validators.age.EAgeValidator’,
‘minAge’=>18,
‘maxAge’=>120,
‘allowEmpty’=>false
),
public function rules()
{
// today
$date = new DateTime();
// 18 years ago
$date->sub(new DateInterval('P18Y'));
// maximum birthday
$max = $date->format('Y-m-d');
return [
['empdob', 'date', 'max' => $max, 'tooBig' => 'Must be 18 years old or older'],
...
];
}
Hey! Thank you for your help and time and sorry i couldn’t check it earlier as it was the weekend.
So, I put the Format as said above but nothing changed , it is not working.
It doesn’t show any error as such and accepts the value, so not able to understand what is the problem. I also printed the $max value , it shows correct value like 2001-12-06.