how to calculate the date of birth by giving the date, month, year in the registration page

Is that a thought, or a request?

If it's a request, you'll have to explain your desire quickly and show some effort. Something along the lines of "I want to do X, but I'm not sure how. Can someone suggest a way to me?" or "I want to do X, tried Y, but got Z. How can I do X?"

I believe you want to calculate the age if teh date of birth is given:

If that is the case you can use the following function:

function persons_age($year, $month, $day)
{

//list($year, $month, $day) = split('[-.]', $BirthDate);

   $tmonth = date('n');
   $tday = date('j');
   $tyear = date('Y');
   $years = $tyear - $year;
   if ($tmonth <= $month)
   {
       if ($month == $tmonth)
       {
           if ($day > $tday)
               $years--;
       }
       else
           $years--;
   }
   return $years;
}

Is there a way to determine the year of birth based on the age given? Also, is there a way to tell the function that the year you want to base the age on is 1992? As if the current year was 1992. Does that make sense?

$dob="1980-07-31"; $today=date("Y-m-d");
list($y,$m,$d)=explode('-',$dob);
list($ty,$tm,$td)=explode('-',$today);
if($td-$d<0){
$day=($td+30)-$d;
$tm--;
}
else{
$day=$td-$d;
}
if($tm-$m<0){
$month=($tm+12)-$m;
$ty--;
}
else{
$month=$tm-$m;
}
$year=$ty-$y;
echo $year ." year, ". $month ." months and  ". $day. " Days";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.