- date_create: documentation ( source)
- explode: documentation ( source)
<?php
function berekenLeeftijd($datum) {
$leeftijd= date_create($datum)->diff(date_create('today'))->y;
return $leeftijd;
}
$geboortedatum = '18-05-1970';
$exp = explode('-',$geboortedatum);
echo berekenLeeftijd($exp[2].'-'.$exp[1].'-'.$exp[0]);
?>