Estoy buscando una función que calcula los años a partir de una fecha en formato: 0000-00-00. Encontré esta función, pero no funcionará.Calcular años a partir de la fecha
// Calculate the age from a given birth date
// Example: GetAge("1986-06-18");
function getAge($Birthdate)
{
// Explode the date into meaningful variables
list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $Birthdate);
// Find the differences
$YearDiff = date("Y") - $BirthYear;
$MonthDiff = date("m") - $BirthMonth;
$DayDiff = date("d") - $BirthDay;
// If the birthday has not occured this year
if ($DayDiff < 0 || $MonthDiff < 0)
$YearDiff--;
}
echo getAge('1990-04-04');
salidas nada:/
tengo informar sobre el error, pero no consigo ningún error
Esta función no tiene 'línea de return', por lo que no hace nada de salida. Parece muy incompleto. – deceze