Free Photos
WordPress Themes

Current age in years and months from given birthdate

function age( $birthdate, $divider = "," ){ list( $pjr, $pmnd, $pdg ) = explode( '-', $birthdate ); list( $jr, $mnd, $dg ) = explode( '-', date('Y-m-d') ); $dim = cal_days_in_month(CAL_GREGORIAN, $mnd, $jr) ; $dagen = $dg - $pdg; if ($dagen < 0) { $mnd = $mnd - 1; $dagen = $dim - abs($dagen); } $maanden = $mnd - $pmnd; if ($maanden < 0) { $jr = $jr - 1; $maanden = 12 - abs($maanden); } $jaren = $jr - $pjr; return $jaren . $divider . $maanden; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.