Show age from date of birth custom fields.
I have created 3 custom fields with drop down lists with years, months, days all with a numerical value:
cp_yearofbirth (1900 - 2020)
cp_monthofbirth (01 -12)
By editing the single-ad_listing.php I can show any or all of the fields by using:
<?php echo get_post_meta($post->ID, 'cp_yearofbirth', true); ?> and changing the value.
What I would like to do is use these 3 custom fields to calculate the age of the poster and display it. I know I will have to put the code into the single-ad_listing.php file which is fine as the whole file will be customised anyway.
Does anyone know the code I need to do this?