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!

Comments

Witch’s picture

bump!

cayenne’s picture

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

:)

Anonymous’s picture

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

lelizondo’s picture

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

Luis

Anonymous’s picture

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

lelizondo’s picture

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

Witch’s picture

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?

lelizondo’s picture

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

Witch’s picture

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;
?>
lelizondo’s picture

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

Luis

Witch’s picture

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

lelizondo’s picture

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

Witch’s picture

$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

chrisgelles’s picture

http://drupalsn.com/learn-drupal/drupal-tutorials/user-age-date-birth-–-cck-way

She has a tutorial that will return the user's age.
Though, as a noob, I'm still working on including the birth date fields on the user's profile information...

:)

Love to see what you figure out!