Short explanation:
I’m importing an ics feed in which some events have both start and end times, and some have just start times.
(On import, these events actually show the end time as being the same as the start time. I’m not sure if that’s a reflection of the feed itself, or if that’s what the plugin does when it imports an event with no end time.)
On one of my templates, I want to show the time of the event like this:
<?php eo_the_start('F j, Y'); ?><br/><?php eo_the_start('g:ia'); ?> – <?php eo_the_end('g:ia'); ?>
That works great. But for those events where there is no end time (or, to be specific, where the end time is the same as the start time), I just want this:
<?php eo_the_start('F j, Y'); ?><br/><?php eo_the_start('g:ia'); ?>
So, I want to apply some conditional logic that accomplishes this for me. Something like:
<?php eo_the_start('F j, Y'); ?><br/><?php eo_the_start('g:ia'); ?>
<!-- IF THE END DATE IS AFTER (BUT NOT EQUAL TO) THE START DATE: -->
– <?php eo_the_end('g:ia'); ?>
<!-- ENDIF -->
I’m assuming this is possible. I just want WordPress/EO to examine the two starting times, and then (a) if they’re the same, just display the start rate; or (b) If the end time is after the start time, to display the times one after the other (for example: 7pm – 8:30pm).
Thanks for your help!

Josh Mason-Barkin
Hi Josh,
Regarding the iCal feed, the plug-in is not behaving correctly for all-day events. From the iCal specification:
For cases where a “VEVENT” calendar component specifies a “DTSTART” property with a DATE value type but no “DTEND” nor “DURATION” property, the event’s duration is taken to be one day. For cases where a “VEVENT” calendar component specifies a “DTSTART” property with a DATE-TIME value type but no “DTEND” property, the event ends on the same calendar date and time of day specified by the “DTSTART” property.
At present the plug-in will just set the end date/datetime of the event to the start date/datetime if it is not provided. This is correct behaviour (as far as the iCal specification is concerned) for date values, but not datetime. The latter is a bug (I’ve raised a ticket here, thanks for reporting it!), and will be fixed in due course.
Regarding the second part of your question, there is a template function coming in 3.0.0 which will do exactly what you’re after. Until then you’ll need to it manually. You can use eo_get_the_start()
and eo_get_the_end()
to return the datetimes in a specific format and compare the two:
if ( eo_get_the_start( 'Y-m-d H:i:s' ) == eo_get_the_start( 'Y-m-d H:i:s' ) ) {
//event starts & ends on the same datetime
}
Of course, you can just adjust the format Y-m-d H:i:s
to just compare the date part (does this event end on the same day as it starts) or the year and month component (does this event end in the same month as it starts).

Stephen Harris