Show the end date only if end date (not end time) is different than start date

Home Forums Welcome! Pre-Sales Questions Show the end date only if end date (not end time) is different than start date

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1378175
    jessewhite
    Participant

    I need to display the dates for events in this format: “1 Oct” for a single day event and “1 to 2 Oct” for a multi-day event. The code I have so far works except on single day events that aren’t All Day Events. For that situation, my code outputs “1 to 1 Oct”. I assume it’s because the start time does not equal the end time. How do I change this so it compares only the date and not the time?

    
    <?php echo tribe_get_start_date( null, false, 'j' ); ?>          <!-- display start date -->
    <?php if (tribe_get_start_date() !== tribe_get_end_date() ) { ?> <!-- if start/end dates are different -->
    to <?php echo tribe_get_end_date( null, false, 'j' ); ?>         <!-- display end date -->
    <?php } ?>
    <br>
    <?php echo tribe_get_start_date( null, false, 'M' ); ?>          <!-- display month -->
    
    #1378399
    jessewhite
    Participant

    The problem was that I didn’t include the parameters ( null, false ) in the if statement.

    #1378894

    Glad you were able to resolve your issue, you are welcome back in our support forums any time!

    For now, I am going to close this thread.

    Have a great week!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Show the end date only if end date (not end time) is different than start date’ is closed to new replies.