PDA

View Full Version : Help work out age in PHP



The_Vulcan
July 19th, 2004, 02:10 PM
Ok this is simple but I don't know jack about mysql or php.

In flash I have a "dob" list box.

This pulls the dob from mysql in the for of "1989"

$dob = mysql_result($fewComments, $i, 'dob');


This is where I am sending that information to flash, but I dont want to send 1989, I want to send 15.


print "<br>&writeage=";
if($numallComments == 0) { print " No entries yet.."; }
else { $i = 0;
$dob = mysql_result($fewComments, $i, 'dob');
print'<b>Age: </b>'. $dob .'';}

I am assuming it is CURRENTDATE() - 1989 but I don't know how to format CURRENTDATE so I can minus 1989


Any help or hints much appreciated...

ol4pr0
July 19th, 2004, 03:16 PM
echo date("Y"); #will return Year if i am not mistaken
Date (www.php.net/date)

The_Vulcan
July 19th, 2004, 03:35 PM
Hey thanks for that ol4pr0

The link showed

$today = date("j, n, Y"); // 10, 3, 2001

which gave me

$today = date("Y");
$dob = $today - $dob;

I thought I tried that or something very close to it.... but then I did try 7 or 8 different variations....

I guess 3 hours sleep in 48hours dont help much either....

Thanks for that.... now I can almost og to bed. :)