Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Calculate Age From Birthdate?


Print Track
I remember a long time ago there was a forum post about how to calculate the age from the Birthdate Userfield. I searched and wasn't able to find the post. Does anyone remember how to do this? I am using PHP-Fusion 7.02. It would be very useful on my age restricted website.

1 reply

This does it,
CodeDownload  
function getdage($dbdate) {
   list($y,$m,$d) = explode("-",$dbdate);
    $age = date('Y')-$y;
   date('md')<$m.$d ? $age--:null;
    return $age;
}


Call with
CodeDownload  
echo getdage($userdata['user_birthdate']);

author SkeeredOfMyMind
forumCode Snippet and functions - 8
replies2 posts
viewed1,054 times
activeLast updated on 3 years ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: Falk, SkeeredOfMyMind