Last date of recurring event

Home Forums Calendar Products Events Calendar PRO Last date of recurring event

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #720045
    dkinney
    Participant

    In the case of an event that runs September 5 to November 16, I need to get the November 16 date, the LAST date of the recurrence to use in a template. I tried the code snippet referenced here https://theeventscalendar.com/support/forums/topic/is-there-a-way-to-get-the-post-id-of-the-event/
    but that gave me September 5, the date of the current event, not the last day in the series.

    #720727
    Josh
    Participant

    Hello dkinney,

    Thanks for reaching out to us!

    I took a look at that snippet and it looks like it can only be used to find the start date. To find the end date you’ll need to use the “_EventRecurrence” meta and access the “end” date there. Here is an example of the previous snippet modified to get the last event date for a recurring event.

    
    <?php 
    $recurrence = get_post_meta( get_the_ID(), '_EventRecurrence', false );
    
    foreach( $recurrence as $events ) {
    $last_event = $events[end];
    }
    
    $final_date = date( get_option('date_format'), strtotime($last_event) );
    echo "The last event takes place on $final_date.";
    

    Let me know if this works for you.

    Thanks!

    #722167
    dkinney
    Participant

    Thank you

    #722519
    Josh
    Participant

    Hello Diane,

    No problem! Happy to be able to help.

    If you have a few moments, we would definitely appreciate a review for our plugin on the WordPress repository.

    I’m going to go ahead and close this ticket. If you have any further questions please don’t hesitate to open a new one.

    Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Last date of recurring event’ is closed to new replies.