• How could I calculate an person’s age if I have their year of birth?

    Thanks heaps
    Tim

    ——————————————
    EDIT:

    Im trying this function:

    function age_in_years() {
    	global $postmeta;
    	$year_of_birth = get_field( "date_of_birth",$modelID);
    	$date1 = strval( $year_of_birth );
    	$date2 = strval( date( 'yy') );
    	$age = $date2 = $date1;
    	return $age;
    }

    But is not working at all… what I am doing wrong?
    Using this code:
    <?php echo age_in_years();?>

    Is getting this:
    05/07/1992

    Database screenshot: https://i.imgur.com/mjLrEQx.png

    https://www.ads-software.com/plugins/advanced-custom-fields/~

    Waiting for your help, thanks ??

  • The topic ‘How to calculate age?’ is closed to new replies.