I am having trouble getting my script to calculate age, I have the birthday being pulled from a database and I want the script to recongize that date as the birthdate. The Format it comes out of my database is year/month/date I keep getting strange results with the script that I found on from looking up how to do this.
echo "Player Name: ".$row['FirstName']." ".$row['LastName']."<br>";
echo "Position: ".$row['Position']."<br>";
echo "Height: ".$row['Height']."<br>";
echo "Weight: ".$row['Weight']."<br>";
echo "Birthdate: ".$row['DOB']."<br>";
echo //date in yyyy.mm.dd format; or it can be in other formats as well
$DOB = "2001.12.31";
//explode the date to get year, month and day
$DOB = explode(".", $DOB);
//get age from date or DOB
$age = (date("md", date("U", mktime(0, 0, 0, $DOB[0], $DOB[1], $DOB[2]))) > date("md") ? ((date("Y")-$DOB[2])-1):(date("Y")-$DOB[2]));
echo "Age is:".$age."<br>";
echo "CNGHL Team: ".$row['CNGHLRights']."<br>";
echo "NHL Team: ".$row['Team']."<br>";
echo "Draft Year: ".$row['CNDraftYR']."<br>";
echo "Draft Position: ".$row['CNDraftPOS']."<br>";
echo "Drafted By: ".$row['CNDraftTEAM']."<br>";
echo "<img src=\"http://www.cnghl.info/cnghldb/images/".$iPlayerID.".jpg\">";
It pulls from the date inside the script 2001.12.31 rather then the date that the script pulls from the database with the DOB.
Any help would be greatly appreciated.
Thanks!