Function to display end date only if it's a different month than start date

Home Forums Welcome! Pre-Sales Questions Function to display end date only if it's a different month than start date

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1356007
    Caroline
    Guest

    I am looking for a way to display an event’s end date only if the event spans over more than one month. Here is the code I’m working with:


    <!-- Schedule & Recurrence Details -->
    <div class="tribe-event-schedule-details">
    <div class="month">
    <span><?php echo tribe_get_start_date( null, false, 'M' ); ?> </span>
    </div>

    <div class="dates">
    <span class="start-date">
    <?php echo tribe_get_start_date( null, false, 'j' ); ?>
    </span>

    <span class="end-date">
    <?php if ( tribe_event_is_multiday( $event ) ) : ?>
    <span class="sep">-</span>
    <?php echo tribe_get_end_date( null, false, 'j' ); ?>
    <?php endif; ?>
    </span>
    </div>
    </div>

    This has been working pretty well for me and yield results that look like this. The problem I’m running into is with events that run over multiple months, where it ends up looking like this (and event that runs from September to October).

    I would like to be able to display the name of the end date’s month only in these instances. Is this possible?

    #1356544
    Caroline
    Member

    Hi Caroline,

    Thanks for reaching out! While customizations such as this are typically beyond the scope of what support services we provide, I’ve adapted your code a bit to get you started here. Feel free to make further adjustments as needed to fit your theme and styling!

    https://gist.github.com/mia-caro/359cbe7c6e7b1a5e096e7207637041c9

    I hope that helps to get you on your way! 🙂 Cheers, and best of luck getting things set up properly on your site!

    #1356667
    Caroline
    Guest

    THANK YOU. This is precisely what I needed and I knew it wouldn’t be too terribly complicated. I appreciate it so much.

    #1357793
    Caroline
    Member

    Hi Caroline,

    You’re so very welcome–glad that I could assist, and always happy to help out a fellow Caroline! 😉 I’m going to go ahead and close this thread out since your question here is resolved, but please don’t hesitate to follow up with a new thread if there’s anything else we can do for you! Cheers, and happy calendar-ing!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Function to display end date only if it's a different month than start date’ is closed to new replies.