Check age from DoB in PHP

Aug 11, 2013
Check age from DoB in PHP
  • To check someone's age from their date of birth:

    PHP:
    $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);