/** * Formatted Dates * Returns either the event's date or both start and end date if the event spans more than * one date * * Format: * Jun 7th - Jun 10th * * @param SS_Datetime $startObj * @param SS_Datetime $endObj * @return string */ public static function formatted_dates($startObj, $endObj) { //Checking if end date is set $endDateIsset = true; if (isset($endObj->value)) { $endDateIsset = false; } $startTime = strtotime($startObj->value); $endTime = strtotime($endObj->value); $startMonth = date('M', $startTime); $startDayOfMonth = $startObj->DayOfMonth(true); $str = $startMonth . ' ' . $startDayOfMonth; if (date('Y-m-d', $startTime) == date('Y-m-d', $endTime)) { //one date - str. has already been written } else { //two dates if ($endDateIsset) { $endMonth = date('M', $endTime); $endDayOfMonth = $endObj->DayOfMonth(true); if ($startMonth == $endMonth) { $str .= ' - ' . $endDayOfMonth; } else { $str .= ' - ' . $endMonth . ' ' . $endDayOfMonth; } } } return $str; }