Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created February 18, 2016 00:18
Show Gist options
  • Save joshfeck/ba5d11cb8489667ce209 to your computer and use it in GitHub Desktop.
Save joshfeck/ba5d11cb8489667ce209 to your computer and use it in GitHub Desktop.
Prints a message regarding the duration of the event. For Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', 'ee_print_event_duration', 10 );
function ee_print_event_duration( $event ) {
$datetimes = $event->datetimes();
foreach($datetimes as $datetime){
if ( $datetime instanceof EE_Datetime ) {
$start = $datetime->get_raw('DTT_EVT_start');
$end = $datetime->get_raw('DTT_EVT_end');
$diff = $end - $start;
$hours = $diff / 3600;
echo '<div><strong>This is ' . $hours . ' hours in duration</strong></div>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment