Drupal:根据出生日期计算年龄
来自站长百科
在一个计算型字段中使用如下代码来根据某人的出生日期计算他的当前年龄:
$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;