Developer Snippet Diary

PHP Age Calculator , Enter your date of birth and know how many years, days, hours, minutes , seconds you are old

echo ''.print_r(getAge(1997,5,1),true).'';

function getAge($year,$month,$day,$hour=0,$minute=0,$second=0){
 $age = mktime($hour,$minute,$second,$month,$day,$year);
 $age = time()-$age;
 return array('years'=>$age/60/60/24/365,
  'months'=>$age/60/60/24/12,
  'weeks'=>$age/60/60/24/7,
  'days'=>$age/60/60/24,
  'hours'=>$age/60/60,
  'minutes'=>$age/60,
  'seconds'=>$age);
}
Posted by: R GONDAL
Email: rizikmw@gmail.com