How can one convert a date string into a UNIX timestamp for age calculation in PHP?

To convert a date string into a UNIX timestamp for age calculation in PHP, you can use the strtotime() function to convert the date string into a UNIX timestamp. Once you have the UNIX timestamp, you can then calculate the age by subtracting the timestamp from the current time and converting the result into years.

$dateString = '1990-05-15'; // Date string to convert
$timestamp = strtotime($dateString); // Convert date string to UNIX timestamp
$age = floor((time() - $timestamp) / 31556926); // Calculate age in years
echo $age; // Output the age