Calcuate Age on Member-loop.php?
-
How do you calculate age in the member-loop.php?
I’ve got the age to calculate in member-header.php with this code
function bpdev_get_age_from_dob($birthdate,$user_id=false,$format=”%y Years, %m Month(s), %d days”){
if(!$user_id)
$user_id=bp_get_member_user_id();
$dob_time=xprofile_get_field_data($birthdate, $user_id);//get the datetime as myswl datetime
$dob = new DateTime($dob_time);
$today = new DateTime();
$diff = round(abs($today->format(‘U’) – $dob->format(‘U’)) / (60*60*24*365));
return $diff;
}And outputting with
<<?php echo “Age:”.bpdev_get_age_from_dob(“birthday”); ?>
Does not seem to work
when I place this code in the member-loop.php
- The topic ‘Calcuate Age on Member-loop.php?’ is closed to new replies.