protected function eventHasBeenFinished(Node $node) {
    // Use the start date when the end date is not set to determine if the
    // event is closed.
    /** @var \Drupal\Core\Datetime\DrupalDateTime $check_end_date */
    $check_end_date = $node->field_event_date->date;

    if (isset($node->field_event_date_end->date)) {
      $check_end_date = $node->field_event_date_end->date;
    }

    $current_time = new DrupalDateTime();

    // The event has finished if the end date is smaller than the current date.
    if ($current_time > $check_end_date) {
      return TRUE;
    }
    return FALSE;
  }
protected function eventHasBeenFinished(Node $node) {
    // Use the start date when the end date is not set to determine if the
    // event is closed.
    /** @var \Drupal\Core\Datetime\DrupalDateTime $check_end_date */
    $check_end_date = $node->field_event_date->date;

    if (isset($node->field_event_date_end->date)) {
      $check_end_date = $node->field_event_date_end->date;
    }

    $current_time = new DrupalDateTime();

    // The event has finished if the end date is smaller than the current date.
    if ($current_time > $check_end_date) {
      return TRUE;
    }
    return FALSE;
  }
protected function eventHasBeenFinished ( Node $ node ) { // Use the start date when the end date is not set to determine if the // event is closed. /** @var \Drupal\Core\Datetime\DrupalDateTime $check_end_date */ $ check_end_date = $ node -> field_event_date -> date ; if ( isset ( $ node -> field_event_date_end -> date ) ) { $ check_end_date = $ node -> field_event_date_end -> date ; } $ current_time = new DrupalDateTime ( ) ; // The event has finished if the end date is smaller than the current date. if ( $ current_time > $ check_end_date ) { return TRUE ; } return FALSE ; }
Function to determine if an event has been finished.

@param \Drupal\node\Entity\Node $node
The event.

@return bool
TRUE if the evens is finished / completed.
Function to determine if an event has been finished .