Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

suge1w on "Calculate age from 3 terms"

$
0
0

I've struggling to find a solution to this.

I have three taxonomies: 'dob', 'mob', 'yob' and I'm trying to calculate the age in years using all 3.

The code I've been messing with:

function age_in_years() {
global $post;
$year_of_birth = get_post_meta( get_the_ID( $post->ID ), 'yob', true );
$date1 = strval( $year_of_birth );
$date2 = strval( date( 'Y') );
$age = $date2 - $date1;
return $age;
}

Could anyone lend a hand?


Viewing all articles
Browse latest Browse all 8245

Trending Articles