Hello all,
It's been a while since I've been on here. I have a coding problem. The system is PHP-Fusion ver7.00.05. Another user created a birthday display panel and there are some time calculation errors in his logic that I can't seem to figure out. Its supposed to display users with birthdays in the current month.
OK... I have set some users birthdays to the current month just for testing purposes with varying years of birth. Some display fine but some show a minus value for age. Here is the code:
while ($db = dbarray($result)) {
$date = explode ("-", $db['user_birthdate']);
$now = date("Y");
if ($date[2] == date("d")) {
$present = "<img src='".INFUSIONS."upcoming_birthday_panel/images/birthday.gif' alt='' border='0' />\n";
} else {
$present = "";
}
$thistime = time() - mktime(0,0,0,$date['1'],$date['2'],$date['0']);
$thistimee = date("Y",$thistime) -1970;
if ($date[2] > date("d")) { $thistimee = $thistimee + 1; } else { $thistimee = $thistimee; }
echo "On ".$date[1]."/".$date[2]."/".$now." ";
echo "<a href='".BASEDIR."profile.php?lookup=".$db['user_id']."' title='".$db['user_name']."'>".$db['user_name']." </a><br />will be ";
echo "(<b>".$thistimee."</b> yrs old) ".$present."<br /><br />";
}The users birthdate is stored in the database as: (Y-M-D) i.e.
1949-11-03 would be my birthdate. I changed mine to 1949-04-05 and it shows correctly that I will be 60 yrs old on today. I changed another user to 1958-04-27 and it correctly shows that he will be 51 on the 27th of April. Another user I changed to 1929-04-17 and the display shows that he will be -56 yrs old on the 17th of April. I do not understand why the other coder is using the value of [-1970] in his calculation and I think that is part of the source of the problem. Any help would be appreciated.
