How can PHP be used to convert a birthdate to an age for search functionality?
To convert a birthdate to an age for search functionality in PHP, you can use the DateTime class to calculate the difference between the birthdate and the current date. This will give you the age of the person. You can then use this age for search queries or comparisons.
$birthdate = '1990-05-15';
$today = new DateTime();
$diff = $today->diff(new DateTime($birthdate));
$age = $diff->y;
echo "Age: " . $age;