le 30/08/2003 à 18:50
XTremTourist
et g un probleme pour calculer l age d une personne depuis sa date de naisance
voila ce qui me retourne apret interpretation du code
Warning: mktime(): Windows does not support negative values for this function in H:\server\www\test\age_d_personne.php on line 12
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in H:\server\www\test\age_d_personne.php on line 3
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in H:\server\www\test\age_d_personne.php on line 4
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in H:\server\www\test\age_d_personne.php on line 4
2003 << sa c le echo $age;
PD de windows enfait se serait pas windows mais lostdown
<?php
function calculAge ($dateNaissance, $dateReference) {
$age = date("Y",$dateReference) - date("Y",$dateNaissance);
if( (mktime(0,0,0, date("n", $dateReference), date("j", $dateReference), date("Y", $dateReference)) - mktime(0,0,0, date("n", $dateNaissance), date("j", $dateNaissance), date("Y", $dateReference))) < 0 ) {
$age--;
}
return $age;
}
// exemple d'utilisation (cf. la fonction mktime pour plus de details) :
$naissance = mktime (20, 30, 00, 04, 20, 1969);
$reference = time();
// notez que time() retourne aussi un timestamp : le timestamp de l'instant present (en clair, là, on calcul l'age de la personne à l'instant présent)
$age = calculAge ($naissance, $reference);
echo $age;
?>
voila ce qui me retourne apret interpretation du code
Warning: mktime(): Windows does not support negative values for this function in H:\server\www\test\age_d_personne.php on line 12
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in H:\server\www\test\age_d_personne.php on line 3
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in H:\server\www\test\age_d_personne.php on line 4
Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in H:\server\www\test\age_d_personne.php on line 4
2003 << sa c le echo $age;
PD de windows enfait se serait pas windows mais lostdown