<?php function getAge($dob) { $today = date("Y-m-d"); $diff = date_diff(date_create($dob), date_create($today)); return $diff->format('%yYears, %mMonths, %dDays'); } echo getAge('19-10-1988'); ?>