In Settings > Formatting set the time format without the timezone. Then you could create a custom placeholder called #_MYEVENTTIMES using the following code snippet:
add_filter('em_event_output_placeholder', function($replace, $EM_Event, $result) {
if (preg_match('/#_MYEVENTTIMES.*/', $result)) {
$replace = $EM_Event->output_times() . '(' . $EM_Event->start()->i18n('e') . ')';
}
return $replace;
}, 10, 3);You could use the Code Snippets plugin to add this code snippet.
Here’s a tutorial on creating custom placeholders: https://wp-events-plugin.com/documentation/tutorials/create-a-custom-placeholder-for-event-formatting/
Thank you so much! That works great as an alternative for #_EVENTTIMES, although it also includes the timezone on “all day” events, which is unnecessary — I’ve been looking to see if there might be a way around that.
We are also trying to figure out how to do the same thing as an alternative for #_EVENTIMES_LOCAL, but am not quite sure the variable to modify for that placeholder.
I’m wondering if it might not be easier to just create a custom placeholder just for the event timezone and the event local timezone so they could be output independently of the start/end times…
I came up with this as a function to supply a placeholder with just the local timezone. Happy to hear suggestions for improvement!
add_filter('em_event_output_placeholder', function($replace, $EM_Event, $result) {
if (preg_match('/#_MYEVENTTIMEZONE_LOCAL.*/', $result)) {
$rand = rand();
ob_start();
?>
<span id="em-start-local-timezone-<?php echo $rand ?>">JavaScript Disabled</span>
<script>
document.getElementById("em-start-local-timezone-<?php echo $rand ?>").innerHTML = Intl.DateTimeFormat().resolvedOptions().timeZone;
</script>
<?php
$replace = ob_get_clean();
}
return $replace;
}, 10, 3);
Also, if I’m not mistaken there is already an undocumented #_EVENTTIMEZONE placeholder, so it seems like one could solve the first need here using something like:
#_24HSTARTTIME–#_24HENDTIME (#_EVENTTIMEZONE)
I guess there is also an undocumented #_EVENTTIMEZONE_LOCAL placeholder, so it seems like one could solve the same need for local times using something like:
#_24HSTARTTIME_LOCAL–#_24HENDTIME_LOCAL #_EVENTTIMEZONE_LOCALThe only issue is that because of the JS scripting, #_EVENTTIMEZONE_LOCAL results have whitespace around them and so putting characters around the placeholder like:
(#_EVENTTIMEZONE_LOCAL)displays something like:
( #_EVENTTIMEZONE_LOCAL )
Glad to hear you were able to figure this out. I don’t know how to get rid of the spaces.
Thanks for your help! It solved the initial need and set me off on the right track for another solution!
