Hi, I've enabled computed field module and added the following birthday code to the data settings box as indicated on the project homepage:
$birthday_date = date_make_date($node->field__[0]['value']);
$birthday = $birthday_date->db->parts;
//compute age
$bdayunix = mktime("", "", "", $birthday['mon'], $birthday['mday'],
$birthday['year']);
$nowunix = time();
$unixage = $nowunix - $bdayunix;
$age = floor($unixage/ (365 * 24 * 60 * 60));
$node_field[0]['value'] = $age;
Not being versed in php I'm afraid I'm missing something terribly important here, one of which is figuring out what I'm supposed to put in the display format and data type sections. I also don't understand the references to nowunix or birthday_date. I've created a date content field for the user to select their birthday based on month-day-year but don't know how to apply it here.
Has anyone done this using this code and if so would you mind sharing the steps to get to the point where the field translates the date to the age in years?
THank you very much.
Comments
Comment #1
colanVersion 5 is no longer supported.