Hello,
I'm trying to calculate hours difference in my content type. I have "start date" and "end date" when the form is filled. I'm not sure what am I doing wrong, so any help would be appreciated.
Strict warning: Only variables should be passed by reference in eval() (line 1 of /computed_field/computed_field.module(394) : eval()'d code)
Strict warning: Only variables should be passed by reference in eval() (line 2 of /computed_field/computed_field.module(394) : eval()'d code)
Warning: array_pop() expects parameter 1 to be array, boolean given in eval() (line 2 of /computed_field/computed_field.module(394) : eval()'d code).
Here is the code that I'm using for calculation:
$start_date = array_pop(field_get_items($entity_type, $entity, 'field_status_pocetak_prijava'));
$end_date = array_pop(field_get_items($entity_type, $entity, 'field_status_kraj_prijava'));
$start_date = new DateObject($start_date['value'], '');
$end_date = new DateObject($end_date['value'], '');
$duration = $start_date->difference($end_date, 'hours');
$duration = $duration = floor($duration);
$entity_field[0]['value'] = $duration;
Comments
Comment #2
hosisam commentedYou should use this
Computed Code (PHP)
Display Code (PHP)
Comment #3
avpaderno