public function getAge()
    {
        if (!$this->hasDateOfBirth()) {
            return 0;
        }

        $currentTimestamp = $GLOBALS['EXEC_TIME'];
        $birthTimestamp = $this->getDateOfBirth();

        $currentYear = (int)strftime('%Y', $currentTimestamp);
        $currentMonth = (int)strftime('%m', $currentTimestamp);
        $currentDay = (int)strftime('%d', $currentTimestamp);
        $birthYear = (int)strftime('%Y', $birthTimestamp);
        $birthMonth = (int)strftime('%m', $birthTimestamp);
        $birthDay = (int)strftime('%d', $birthTimestamp);

        $age = $currentYear - $birthYear;

        if ($currentMonth < $birthMonth) {
            $age--;
        } elseif ($currentMonth === $birthMonth) {
            if ($currentDay < $birthDay) {
                $age--;
            }
        }

        return $age;
    }
public function getAge()
    {
        if (!$this->hasDateOfBirth()) {
            return 0;
        }

        $currentTimestamp = $GLOBALS['EXEC_TIME'];
        $birthTimestamp = $this->getDateOfBirth();

        $currentYear = (int)strftime('%Y', $currentTimestamp);
        $currentMonth = (int)strftime('%m', $currentTimestamp);
        $currentDay = (int)strftime('%d', $currentTimestamp);
        $birthYear = (int)strftime('%Y', $birthTimestamp);
        $birthMonth = (int)strftime('%m', $birthTimestamp);
        $birthDay = (int)strftime('%d', $birthTimestamp);

        $age = $currentYear - $birthYear;

        if ($currentMonth < $birthMonth) {
            $age--;
        } elseif ($currentMonth === $birthMonth) {
            if ($currentDay < $birthDay) {
                $age--;
            }
        }

        return $age;
    }
public function getAge ( ) { if ( ! $ this -> hasDateOfBirth ( ) ) { return 0 ; } $ currentTimestamp = $ GLOBALS [ 'EXEC_TIME' ] ; $ birthTimestamp = $ this -> getDateOfBirth ( ) ; $ currentYear = ( int ) strftime ( '%Y' , $ currentTimestamp ) ; $ currentMonth = ( int ) strftime ( '%m' , $ currentTimestamp ) ; $ currentDay = ( int ) strftime ( '%d' , $ currentTimestamp ) ; $ birthYear = ( int ) strftime ( '%Y' , $ birthTimestamp ) ; $ birthMonth = ( int ) strftime ( '%m' , $ birthTimestamp ) ; $ birthDay = ( int ) strftime ( '%d' , $ birthTimestamp ) ; $ age = $ currentYear - $ birthYear ; if ( $ currentMonth < $ birthMonth ) { $ age -- ; } elseif ( $ currentMonth === $ birthMonth ) { if ( $ currentDay < $ birthDay ) { $ age -- ; } } return $ age ; }
Returns this user's age in years.

Note: This function only works correctly for users that were born after
1970-01-01 and that were not born in the future.

@return int this user's age in years, will be 0 if this user has no birth date set
Returns this user s age in years .