function getFriendlyDateRange($startDateTime, $endDateTime) { $tense = getEventTense($startDateTime, $endDateTime); $currentTime = time(); $dayAndMonthSame = $daySame && $monthSame; $dateSame = $daySame && $monthSame && $yearSame; // find out if month, day, if ($tense == 'past') { $formattedDate = 'Ended ' . date("M jS, o", $endDateTime); } else { $startDay = date("j", $startDateTime); $startMonth = date("m", $startDateTime); $startYear = date("o", $startDateTime); $endDay = date("j", $endDateTime); $endMonth = date("m", $endDateTime); $endYear = date("o", $endDateTime); $daySame = $startDay == $endDay; $monthSame = $startMonth == $endMonth; $yearSame = $startYear == $endYear; if (!$yearSame) { // Jan 4th 2016, 6:00pm - Jan 4th 2017, 4:00pm $formattedDate = date("D, M jS o, g:ia", $startDateTime) . ' - ' . date("D, M jS o, g:ia", $endDateTime); } else { if (!$monthSame) { // Jan 30th, 6:00pm - Feb 1st, 1:00am, 2016 $formattedDate = date("D, M jS, g:ia", $startDateTime) . ' - ' . date("D, M jS, g:ia, o", $endDateTime); } else { if (!$daySame) { // Feb 20th, 1:15pm - Feb 21st, 2:55pm, 2016 $formattedDate = date("D, M jS, g:ia", $startDateTime) . ' - ' . date("D, M jS, g:ia, o", $endDateTime); } else { // Feb 20th, 1:15pm - 2:55pm, 2016 $formattedDate = date("D, M jS, g:ia", $startDateTime) . ' - ' . date("g:ia, o", $endDateTime); } } if ($tense == 'present') { $formattedDate = 'Happening Now: ' . $formattedDate; } } } return $formattedDate; }
include_once 'header.php'; ?> <?php while (have_posts()) { the_post(); ?> <!-- Set all the needed variables and call all needed functions --> <?php $conferenceEvents = getConferenceEvents($post->ID); $eventDate = get_field('start_time'); $startTime = get_field('start_time'); $endTime = get_field('end_time'); $location = get_field('location'); $eventTense = getEventTense($startTime, $endTime); $isRecurringEvent = isRecurringEvent($post->ID); $googleCalStart = date("Ymd\\THis\\Z", strtotime('+5 hours', $startTime)); $googleCalEnd = $endTime && $endTime != '' ? date("Ymd\\THis\\Z", strtotime('+5 hours', $endTime)) : $googleCalEnd; $googleCalLink = 'https://www.google.com/calendar/render?action=TEMPLATE&text=' . get_the_title() . '&dates=' . $googleCalStart . '/' . $googleCalEnd . '&details=' . get_the_excerpt() . '--%20More%20Info:' . get_permalink() . '&location=' . $location; $wrapUpLink = get_field('wrap_up_link'); $registrationLink = get_field('registration_link'); $showNextEventLink = $eventTense == 'past' && $isRecurringEvent ? true : false; if ($showNextEventLink) { $nextRecurringEventLink = getNextRecurringEventLink($post->ID, $eventDate); $name = getRecurringEventName($post->ID); } $showWrapUpLink = $eventTense == 'past' && $wrapUpLink != "" ? true : false; $showRegistrationLink = $eventTense != 'past' && $registrationLink != '' ? true : false; $sponsors = get_field('sponsors'); $post_footer = get_field('post_footer');