Hi,
I have a computed field with code (below) to calculate the age range of cats. When the cat has a birthday I need the age range to change. I tried using your module but it didn't seem to work. I know I'm not using Nodes Taxonomies, so does the tool not work for my code? Are you working on developing it to work or should I try a different module?
Thanks so much,

$dob = $entity->field_birthday_cats['und'][0]['value'];
$now = time();
$then = strtotime($dob);

$diff = date('Y', $now) - date('Y', $then);
$mdiff =""; $mdiff = date('m', $now) - date('m', $then);

if (($diff ==0)) {$age = "Kitten";}
elseif(($diff ==1) && (date('z',$now) < date('z',$then))) {$age = "Kitten";}
elseif ($diff ==1){ $age = "Young"; }
elseif (($diff >1) && ($diff <4)){ $age = "Young"; }
elseif ($diff ==4){ $age = "Adult"; }
elseif (($diff >3) && ($diff <11)){ $age = "Adult"; }
elseif (($diff == 11) && (date('z',$now) < date('z',$then))){ $age = "Adult"; }
else {$age = "Senior"; }

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

Comments

frakke’s picture

What is the type of the field field_birthday_cats?

LTech’s picture

Field : Date (ISO format)
Widget: Text field