public function EventMeta::getDateString in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/EventMeta.php \Drupal\rng\EventMeta::getDateString()
@inheritDoc
Overrides EventMetaInterface::getDateString
File
- src/
EventMeta.php, line 719
Class
- EventMeta
- Meta event wrapper for RNG.
Namespace
Drupal\rngCode
public function getDateString() {
$event_type = $this
->getEventType();
$start_field = $event_type
->getEventStartDateField();
$end_field = $event_type
->getEventEndDateField();
$event = $this
->getEvent();
$start = $event
->get($start_field)->value;
$count = $event
->get($end_field)
->count();
$end_value = $event
->get($end_field)
->get($count - 1);
if (!empty($end_value->end_value)) {
$end = $end_value->end_value;
}
else {
$end = $end_value->value;
}
$start_date = date('F j, Y', strtotime($start));
$end_date = date('F j, Y', strtotime($end));
if ($start_date == $end_date) {
return $start_date;
}
return date('F j', strtotime($start)) . ' - ' . date('j, Y', strtotime($end));
}