Check age from DoB in PHP

  • Views Views: 11,389
  • Last updated Last updated:
  • 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);
Back
Top