note 78908 deleted from function.mktime by felipe
| From: | felipe@php.net | Date: | Sun, 16 Dec 2007 11:08:38 +0000 |
| Subject: | note 78908 deleted from function.mktime by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133643@lists.php.net to get a copy of this message | ||
Note Submitter: alexixalex at gmail dot com
----
// a simple way to calculate the age of someone
function age($format,$birthday,$today)
{
$birthday_ex = explode("$format",$birthday);
$actdate_ex = explode("$format",$today);
$tempage = ($actdate_ex[2] - $birthday_ex[2]);
$birth = mktime(0,0,0,$actdate_ex[0],$actdate_ex[1]);
$now = mktime(0,0,0,$birthday_ex[0],$birthday_ex[1]);
if ( $now < $birth)
{
$age = $tempage ;
echo $age;
}
else
{
$age = $tempage - 1 ;
echo $age;
}
}