- $startDate = strftime("%x", strtotime($event->start_time));
- $startTime = strftime("%R", strtotime($event->start_time));
+ $now = new DateTime();
+ $startDate = new DateTime($event->start_time);
+ $endDate = new DateTime($event->end_time);
+ $userTz = new DateTimeZone(common_timezone());
+
+ // Localize the time for the observer
+ $now->setTimeZone($userTz);
+ $startDate->setTimezone($userTz);
+ $endDate->setTimezone($userTz);
+
+ $thisYear = $now->format('Y');
+ $startYear = $startDate->format('Y');
+ $endYear = $endDate->format('Y');
+
+ $dateFmt = 'D, F j, '; // e.g.: Mon, Aug 31
+
+ if ($startYear != $thisYear || $endYear != $thisYear) {
+ $dateFmt .= 'Y,'; // append year if we need to think about years
+ }
+
+ $startDateStr = $startDate->format($dateFmt);
+ $endDateStr = $endDate->format($dateFmt);