Voting starts in March for the Drupal Association Board election.
I created a date field called field_bday using CCK in my profile node type, then created a computed field type called age.
Here are the settings I used for the age field.
Label - Age
Widget Type - Computed
Help text - Blank
Default Value PHP Code - Blank
Required - not checked off
Number of values - 1
if (!$node->nid) node_save($node);
$dob = $node->field_bday['value'];
$now = time();
$then = strtotime($dob);
$diff = date('Y', $now) - date('Y', $then);
if($diff < 0) /* ideally you want to prevent this from happening */
echo '??? - negative age.';
if(($diff > 0) && (date('z',$now) < date('z',$then)))
$node_field['value'] = $diff;
field_bday in the second line of code is the variable name for the birthdate field I make using the date widget.
Display this field - checked off.
Display Format -
$display = $node_field_item['value'];
Store using database settings below - checked off
Data type - int
Data length - 3
Default value - blank
Not NULL - checked off
Sortable - checked off
Now... I just need to figure out how to do a computed field to determine the western astrological sign, and possibly the Chinese one as well. I may make little images for each one just to make it cute but that can wait.
Any thoughts on what PHP would go in Computed Code in order to determine the astrological sign? Once I have the western one I can use it as an example to make the Chinese one as well. Smiling I will also post them attached to this question as well so people can use it/them.