how to show a user's age?

Buffer2k - February 16, 2009 - 02:39

i tried to find a working solution for drupal 6, but i guess there is no one.

i created a birthday/date field with cck. but of course it shows only the date, not the age of a user.

its very important for my project to show a user's age.

I am not code with code, i hope someone out there has a working solution for me.

thank you very much!

bump!

Buffer2k - March 1, 2009 - 13:49

bump!

I believe the VIEWS module

Cayenne - March 1, 2009 - 14:25

I believe the VIEWS module lets you express a date as "Time Ago." In the case of a birthday, that is age!

---------------------

"He's said to be outspoken, but nobody's actually seen anyone do it"

What if you are not using

superduperdan - March 19, 2009 - 19:59

What if you are not using Views to display age? I been looking for a module to do such but no luck. Any recommends? =)

------------------------------------------
www.ss-interactive.com
Solutions for interactive design™

Danny

there's

lelizondob - March 19, 2009 - 20:09

there's http://drupal.org/project/birthdays but you'll have to use profiles

Luis

Has anyone successfully

superduperdan - March 20, 2009 - 00:50

Has anyone successfully accomplished this with Birthday module? Any guides would be helpfully. My intention is to valid an age on new user registrations.

------------------------------------------
www.ss-interactive.com
Solutions for interactive design™

Danny

I don't think the original

lelizondob - March 20, 2009 - 01:23

I don't think the original post is to validate the user's age. The Birthday module just takes a profile field and use it to display the users age in a block.

Luis

i will bump this thread one

Buffer2k - March 30, 2009 - 01:58

i will bump this thread one more time.

its very important for my project to calucate users age.

there are some solutions out, especially a computed field solution! can someone give us a instruction how to do this please?

If you're using computed

lelizondob - March 30, 2009 - 02:59

If you're using computed field, then you just have to do the math (see http://drupal.org/node/149228). Also, I don't remember if computed field works on the user registration page.

Luis

Well, i already found this.

Buffer2k - March 31, 2009 - 00:52

Well, i already found this. but its not very good documented.

Does the user has to customize any lines on this code which is here given?

http://drupal.org/node/149237

<?php
$birthday_date
= date_make_date($node->field__[0]['value']);
$birthday = $birthday_date->db->parts;

//compute age
$bdayunix = mktime(0, 0, 0, $birthday['mon'], $birthday['mday'], $birthday['year']);
$nowunix = time();
$unixage = $nowunix - $bdayunix;
$age = floor($unixage/ (365 * 24 * 60 * 60));

$node_field[0]['value'] = $age;
?>

no, not the user. you have to

lelizondob - March 31, 2009 - 01:56

no, not the user. you have to customize it.

Luis

i tried to customize the

Buffer2k - March 31, 2009 - 21:38

i tried to customize the fields, but the field displays alway the number "9". No matter which birthdate is given... :\

well, maybe you're doing

lelizondob - March 31, 2009 - 21:48

well, maybe you're doing something wrong, in the code above the field with the birthday it's "field__" I think that's the only thing you have to change. I never used that code but it doesn't seems to hard to understand.

Luis

$birthday_date =

Buffer2k - April 2, 2009 - 11:45

$birthday_date = date_make_date($node->field_bday[0]['value']);
$birthday = $birthday_date->db->parts;

//compute age
$bdayunix = mktime(0, 0, 0, $birthday['mday'], $birthday['mon'], $birthday['year']);
$nowunix = time();
$unixage = $nowunix - $bdayunix;
$age = floor($unixage/ (365 * 24 * 60 * 60));

$node_field[0]['value'] = $age;

i changed it to the right field

 
 

Drupal is a registered trademark of Dries Buytaert.