See the details here
$app = JFactory::getApplication();
$date= $app->input->getString('tablename___dateelement');
$date = strtotime($date);
$now = time();
$diff = $now - $date;
$years = floor($diff / 31556926);
return ($years >= 18 && $years <= 90);