How to count date difference excluding weekend and holidays?
I should count the number of days between two dates but the weekends and holidays must be excluded from the counting. I used Computed Field.
$start_date_value = array_pop(field_get_items($entity_type, $entity, 'field_date_from'));
$end_date_value = array_pop(field_get_items($entity_type, $entity, 'field_date_to'));
$start_date = new DateObject($start_date_value['value'], '');
$end_date = new DateObject($end_date_value['value'], '');
$entity_field[0]['value'] =$start_date->difference($end_date, 'days');
Here is my working code for counting the days.