Please please if can anyone help I would really appreciate it!
I have managed to get total hours between value 1 and value 2 of my datetime field however I really want to exclude any hours which are in the weekend. I am creating a timesheet for a group of carers and some people will work from a friday night to a saturday morning etc.
this is my code I use atm for calculating the total hours:
$start_value = $entity->field_work_hour_date[LANGUAGE_NONE][0]['value'];
$end_value = $entity->field_work_hour_date[LANGUAGE_NONE][0]['value2'];
$timezone = $entity->field_work_hour_date[LANGUAGE_NONE][0]['timezone'];
$start_date = new DateObject($start_value, $timezone);
$end_date = new DateObject($end_value, $timezone);
$duration = $start_date->difference($end_date, 'hours');
$entity_field[0]['value'] = $duration;
I am still quite new to drupal and php so I would really appreciate any help.
Cheers