$field_cbr_start = field_get_items($entity_type, $entity, "field_project_start");
if($field_cbr_start != NULL)
{
$start_date = $field_cbr_start[0]["value"];
$start = strtotime($start_date);
$field_cbr_end = field_get_items($entity_type, $entity, "field_project_end");
if($field_cbr_end != NULL)
{
$end_date = $field_cbr_end[0]["value"];
$end = strtotime($end_date);
$duration_month=($end-$start)/2592000;
if(isset($end)&&isset($start)) {
$entity_field[0]['value'] = $duration_month;
}
else $entity_field[0]['value'] = NULL;
}
else $entity_field[0]['value'] = NULL;
}
else $entity_field[0]['value'] = NULL;