What resources or tutorials would you recommend for someone looking to improve their PHP skills for tasks like age calculation?

To calculate someone's age in PHP, you can subtract their birth year from the current year. You can then handle cases where the birthday has not yet occurred in the current year by checking the current date against their birthdate.

function calculateAge($birthDate) {
    $birthYear = date('Y', strtotime($birthDate));
    $currentYear = date('Y');
    $age = $currentYear - $birthYear;

    $currentDate = date('md');
    $birthDateFormatted = date('md', strtotime($birthDate));

    if ($currentDate < $birthDateFormatted) {
        $age--;
    }

    return $age;
}

// Example usage
$birthDate = '1990-05-15';
echo 'Age: ' . calculateAge($birthDate);