I don’t understand why none of the WP event plugins have support for time zones.
Using EO for a nation-wide events calendar (e.g. events near you or virtual/webinar events, or even using Bookings) isn’t very flexible when it comes to clearly communicating event times.
CMB2 has a couple great field types: text_datetime_timestamp_timezone (requires PHP 5.3+), select_timezone
Reference: https://github.com/WebDevStudios/CMB2/wiki/Field-Types#types
However, even if I add a custom field for timezone, then I’d need to be able to display events in the user’s timezone. For example, viewing events calendar, lists, etc. I think the quickest implementations (once EO adds a timezone field at time of event creation) would be adding a “view in timezone” selector (that could be auto-selected via a hook that pulls a custom field from the user’s profile).
I brought this same issue up to Calendarize.it and they added viewing support within the week: http://calendarize.it/calendar-showing-events-in-visitors-local-time-zone/
PLEASE “fix/enhance” this to support timezones.
tyvm
Clifford P
Hi Clifford,
I’ll look into this. If it’s a feature that can be provided unobtrusively (as many users will not require the use of multiple timezones) and reliably then it will be added to core, but otherwise could be provided as an extension.Surprisingly or not – this isn’t a much requested feature.
A ‘view in timezone X’ is possible to implement now. If you take that the timezone value you stored as a custom field (or wherever) you could use it as follows:
add_filter( 'eventorganiser_get_the_occurrences_of', function( $occurrences, $event_id ){
$timezone = new DateTimeZone( 'UTC' ); //Set timezone as require
foreach( $occurrences as $occurrence_id => $occurrence ){
$occurrences['start']->setTimeZone( $timezone );
$occurrences['end']->setTimeZone( $timezone );
}
return $occurrences;
}, 10, 2 );
Although I’ve not tested that code it should cover most cases. You will probably also need to use the filter eventorganiser_get_event_schedule
which includes ‘cached’ details such as the schedule start (and last) datetime object, as well other recurrence related data.
Please keep in mind that would still require the event be entered in the site’s timezone.
Stephen Harris
I see the event-meta-event-single.php template
<!-- Single event -->
<div><?php esc_html_e( 'Date', 'eventorganiser' );?>: <?php echo eo_format_event_occurrence();?></div>
<?php } ?>
so I don’t see how I can manipulate that? Is there a simpler way to implement this? Could there be a new meta data field under the event details that allows you to keep WP timezone or set an overrride?
Add an option to show this under the settings option: Select which features events should support
Andy Burns
So that function calls eo_get_the_start
(source). So you could use the eventorganiser_get_the_start
add_filter( 'eventorganiser_get_the_start', function( $formated, $start, $format, $post_id, $occurrence_id ){
$timezone = new DateTimeZone( 'UTC' ); //Set timezone as required
$start->setTimeZone( $timezone );
return eo_format_datetime( $start, $format );
}, 10, 5 );
There is a corresponding eventorganiser_get_the_end
.
Unfortunately to implement multiple timezone support natively would require introducing breaking changes, and require significant rewriting of the code. As this feature isn’t frequently requested, it’s not something that is likely to be implemented.
Stephen Harris