If you looking for showing the user age based on his/her date of birth (Birthday) which is store in database. This can be done by easy way available in PHP. The Code Snippet for Age Calculator in PHP as follows,
PHP Age Calculator
In PHP the following functions are used to calculate the user age,
if ( ! function_exists('age_calculator')) { function age_calculator($dob) { if (isset($dob) && !empty($dob) && strtotime($dob) > 0) { $today = date("Y-m-d"); $diff = date_diff(date_create($dob), date_create($today)); return $diff->format('%y'); } } }
This is a simple way to find the date from any birth date by using PHP function.