Revision: 69929
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 13, 2015 05:26 by apphp-snippets
Initial Code
<?php function age($date){ $time = strtotime($date); if($time === false){ return ''; } $year_diff = ''; $date = date('Y-m-d', $time); list($year,$month,$day) = explode('-',$date); $year_diff = date('Y') - $year; $month_diff = date('m') - $month; $day_diff = date('d') - $day; if ($day_diff < 0 || $month_diff < 0) $year_diff-; return $year_diff; } ?>
Initial URL
http://www.apphp.com/index.php?snippet=php-calculate-age-using-birth-date
Initial Description
This function gets birth date as an argument and it returns the age of the person; it's very useful when building communities or social media sites.
Initial Title
Calculate Age Using a Birth Date
Initial Tags
Initial Language
PHP