I would like to calculate the age of a user from his date of birth, so that when the date of birth is entered in:
<input type="date" name="fecha_nacimiento" id="fecha_nacimiento" class="datepicker" />
and it automatically loads in the
<input type="text" name="edad" id="edad" value="<?php echo $edad;?>" readonly="true"/>
But I do not get it, I currently have this:
<?
function edad($fecha_nacimiento) {
$tiempo = strtotime($fecha);
$ahora = time();
$edad = ($ahora-$tiempo)/(60*60*24*365.25);
$edad = floor($edad);
return $edad;
}
?>
The datepicker format is format: 'yyyy-mm-dd' // foramto de fecha