954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

calculating the date of birth

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

azarudeen
Newbie Poster
10 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

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?"

Puckdropper
Posting Pro
500 posts since Jul 2004
Reputation Points: 23
Solved Threads: 23
 

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;
}

PeppySoft
Newbie Poster
6 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

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?

twilitegxa1
Newbie Poster
1 post since Sep 2008
Reputation Points: 10
Solved Threads: 0
 
$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";
proDharm
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You