Handy snippet for displaying event dates when events can stretch over multiple days.
if (!($startdate==$endate)) { if ($startdate->format('Y-m') === $endate->format('Y-m')) { //if same month echo $startdate->format('F j'); echo '-'; echo $endate->format('j, Y'); } else { //if not same month echo $startdate->format('M j'); echo '-'; echo $endate->format('M j, Y'); } } elseif ($startdate) { // start date and end date are the same date echo $startdate->format('D., F j, Y'); }