Display date differently based on start-end date comparison

WordPress Event Management, Calendars & Registration Forums General Question Display date differently based on start-end date comparison

This topic contains 1 reply, has 1 voice, and was last updated by  Adam Abrams 2 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #40729

    Hi!

    I’m using this in my template to show an event’s date (thanks for your help with this recently):

    $format = "F j, Y g:i a";
    printf("%s  – %s", eo_get_the_start($format), eo_get_the_end($format));
    

    But… I only want to show both dates in full like this if the event is longer than a day (which means it’s a streaming film event and the dates refer to the availability period). Otherwise (for typical screenings where the start and end date are the same day), I’d like to just show the start date/time.

    I tried doing a comparison between eo_get_the_start and eo_get_the_end, but it seems I’m on the wrong track there. How can I achieve something roughly like the following?

    $format = “F j, Y g:i a”;
    if (eo_get_the_end – eo_get_the_start >1) {
    printf(“%s – %s”, eo_get_the_start($format), eo_get_the_end($format));
    } else {
    printf(“%s”, eo_get_the_start($format));
    }

    Hope you can point me in the right direction, thanks!

    Adam Abrams
    #40742

    Sorry! I found the answer right on your FAQ page, “How do I change the format of the dates displayed according to whether the event is a ‘long’ event?”.

    Thanks!
    Adam

    Adam Abrams
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.