Home / PHP Tips Generated By ChatGPT / Calculating the Age from a Date of Birth in PHP Compute someone’s age based on their date of birth. Source Code $birthDate = new DateTime("2000-01-01"); $today = new DateTime("now"); $age = $today->diff($birthDate); echo $age->y; // Outputs the age