diff -u b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php --- b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php @@ -86,18 +86,16 @@ } // Display the date using theme datetime. - $elements[$delta] = [ + $elements[$delta][] = [ '#cache' => [ 'contexts' => [ 'timezone', ], ], - [ - '#theme' => 'time', - '#text' => $output, - '#html' => FALSE, - '#attributes' => ['datetime' => $iso_date], - ], + '#theme' => 'time', + '#text' => $output, + '#html' => FALSE, + '#attributes' => ['datetime' => $iso_date], ]; // Append on the end date. @@ -111,16 +109,17 @@ 'timezone', ], ], - [ - '#theme' => 'time', - '#text' => $output2, - '#html' => FALSE, - '#attributes' => ['datetime' => $iso_date2], - ], + '#theme' => 'time', + '#text' => $output2, + '#html' => FALSE, + '#attributes' => ['datetime' => $iso_date2], ]; } if (!empty($item->_attributes)) { - $elements[$delta]['#attributes'] += $item->_attributes; + $elements[$delta][0]['#attributes'] += $item->_attributes; + if ($this->getFieldSetting('enddate_get') && !empty($output2)) { + $elements[$delta][2]['#attributes'] += $item->_attributes; + } // Unset field item attributes since they have been included in the // formatter output and should not be rendered in the field template. unset($item->_attributes);