Hey Stephen,
Can you please tell me what I’m doing wrong here, or maybe give a quick example how to use this.
I’m trying to use eo_get_current_occurrence_of
on a single event page to show the current date/time of a recurring event…
I tried this:
<?php
$occur = eo_get_current_occurrence_of();
echo $occur['start'];
?>
The problem is nothing’s showing up… What gives?
Thanks for the help!

pach16
Hi pach16, the returned ‘start’ and’end’ values are DateTime objects, so you’ll need to do something like:
$start = $occur['start'];
echo $start->format('jS F Y');
Please note that the function returns false if an occurrence isn’t currently running.

Stephen Harris
Thanks,
Gave that a go, and got error: Fatal error: Call to a member function format() on a non-object in…

pach16
That’ll be because the function is returning false. You’ll need to make sure 1. An occurrence is actually currently running (occurrence start date occurs before now, and ends in the future) and 2. You are calling this from within in the loop (in the event single page this will generally be after the_post()
has been called. Otherwise you’ll need to specify the event ID.
<?php
//Inside the loop:
if( $occur = eo_get_current_occurrence_of() ){
echo 'This event is now running, it will finish at ' . $occur['end']->format('F, d Y g:ia');
}else[
echo 'This event is not currently running';
}
?>

Stephen Harris