philip@hux.co.za Posted October 3, 2007 Share Posted October 3, 2007 hello all i need to determine someones age from there DoB i am currently using this bit of code but it keeps giving the wrong answer //Works out the Age of Person $idyear = $iddate[0].$iddate[1]; $idmonth = $iddate[2].$iddate[3]; $idday = $iddate[4].$iddate[5]; $d1=mktime(0,0,0,$idday,$idmonth,$idyear); $d2=mktime(0,0,0,date("d"),date("m"),date("y")); echo "Your age is ".floor(($d2-$d1)/31536000) . "<br>"; Please help Quote Link to comment https://forums.phpfreaks.com/topic/71665-solved-determining-someones-age-with-php/ Share on other sites More sharing options...
philip@hux.co.za Posted October 4, 2007 Author Share Posted October 4, 2007 ok i figure it out i was putting the day in the wrong position in mktime() function it is first the month then the day.!! go figure thanks anyway Quote Link to comment https://forums.phpfreaks.com/topic/71665-solved-determining-someones-age-with-php/#findComment-361640 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.