getTimestamp(); // convert current time to timestamp $current_timestamp = strtotime("now"); // returns TRUE if past event, FALSE otherwise $variables['event_is_past'] = $current_timestamp > $date_timestamp ?: FALSE; // break up the start and end dates $startDateObj = DateTime::createFromFormat("l, F j, Y - h:ia", $start_date); $event_start_date = $startDateObj->format($dateFormat); $event_start_time = $startDateObj->format('g:ia'); if (!empty($end_date)) { $endDateObj = DateTime::createFromFormat("l, F j, Y - h:ia", $end_date); $event_end_date = $endDateObj->format($dateFormat . ', Y'); $event_end_time = $endDateObj->format('g:ia'); // default to display both the start and end dates $variables['event_date'] = $event_start_date . ' - ' . $event_end_date; // if the start date and end date are equal, display only the end date if ($startDateObj->format($dateFormat . ', Y') == $event_end_date) { $variables['event_date'] = $event_end_date; } // append the start and end times. $variables['event_time'] = $event_start_time . ' - ' . $event_end_time; // If the start and end time are the same, display "All Day" instead. if ($event_start_time == $event_end_time && $event_start_date == $event_end_date) { $variables['event_time'] = t('All Day'); } } else { // If no end date, show only the start date and the text "All Day". $variables['event_date'] = $event_start_date; $variables['event_time'] = t('All Day'); } } } } }