/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function calculateAge ($birthdate) { if (false === $bdt || -1 === $bdt) { return 0; } $nYear = $todayDateParts['year'] - $birthDateParts['year']; $nMonth = $todayDateParts['mon'] - $birthDateParts['mon']; if ($nMonth < 1) { if ($nMonth == 0) { $nDay = $todayDateParts['mday'] - $birthDateParts['mday']; return ($nDay < 0) ? ($nYear - 1) : $nYear; } return ($nYear - 1); } return $nYear; }