View Single Post
08-12-2008, 10:03 PM
#4
Wildhoney is offline Wildhoney
Wildhoney's Avatar
Status: Request a custom title
Join date: Feb 2006
Location: Nottingham
Expertise:
Software:
 
Posts: 1,648
iTrader: 18 / 95%
 

Wildhoney is on a distinguished road

Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney

  Old

As aforesaid. Nonetheless, my first contribution in such a long while will exalt you, mi amigo:

PHP Code:
/* Oh, Wildhoney to the rescue! TalkPHP.com loves you. */
function date_age($iBirthDay$iBirthMonth$iBirthYear)
{
    
/* Determine the current date, sunshine. */
    
list($iCurrentDay$iCurrentMonth$iCurrentYear) = array(date('j'), date('n'), date('Y'));
    
    
/* Quick guess -- maybe incorrect guess at the age. */
    
$iAge $iCurrentYear $iBirthYear;
    
    
/* Was the individual born before the current month, if so, we were right first time. */
    
if ($iBirthMonth $iCurrentMonth)
    {
        return 
$iAge;
    }
    
    
/* It's my birthday and I'll cry if I want to. */
    
if ($iBirthDay <= $iCurrentDay && $iBirthMonth == $iCurrentMonth)
    {
        
/* Without a time, we'll assume the individual's birth time has passed. */
        
return $iAge;
    }
    
    
/* Lucky individual still has birthday presents to look forward to sometime THIS year. */
    
return $iAge 1;
}

printf("Age: %d<br />"date_age(10101985));
printf("Age: %d<br />"date_age(1021985));
printf("Age: %d<br />"date_age(1281985));
printf("Age: %d<br />"date_age(1261989));
printf("Age: %d<br />"date_age(12161899));