Support » Plugin: amr ical events lists » Display event dates using event timezone?

  • Resolved TravisR


    Pardon me if I’ve made some false assumptions, but it appears that the date and time of events is translated to the timezone set for the WordPress installation before the event is displayed, is this correct?

    For example, I’m showing an ICS file that contains an event with the following date/time data:
    DTSTART;TZID=W. Europe Standard Time:20130508T000000
    DTEND;TZID=W. Europe Standard Time:20130509T000000

    When I view this event through the plugin, it shows it as occurring on May 7th if my WordPress timezone setting is anything below UTC+1. If I set the WordPress timezone setting to UTC+1 or higher then the date shows as May 8th.

    Is it possible to set the behavior so that the displayed date corresponds to the date of the event timezone rather than the WordPress timezone? Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author anmari


    Hi Travis,

    ooooh timezones, guaranteed to confuse people no end…

    short answer:
    Yes, plugin converts to website timezone – very thoroughly tested (image daylight saving etc)

    Yes, you can set the page to display in a timezone of your choice with a shortcode parameter:

    How event timezones work

    All events displayed with that shortcode will display in that timezone then. YOu can add a timezone switcher icon to the calendar properties to be displayed so folks can switch timezones if they want.

    However it does NOT currently do a dummy type – just list what the ics file says, potentially having mixed timezones in one listing. Reason for this is that some ics files just list everything in UTC time, so to get events to what people ‘expect’ timezone conversion must be done.
    Also mixing timezones on one page is confusing.

    That said, many of the ‘formatting’ functions are pluggable, so you could write your own to display events (assuming mixed timezones in the ics file) in their ics timezone, clearly indicating the timezone so people don’t get confused.

    Hmm – maybe it could be ‘extra option’ to display multiple times (one set in website time and one in original ics event time.)

    more info :

    These are almost exclusively all-day events that are occurring in multiple time zones and are viewed in multiple time zones, so the ideal option is to just show the event according to the event timezone. I did this by adding a filter on amr_events_after_sort that will convert everything to the local time of the WordPress installation. In case anybody is interested, here’s the code:

    function ConvertEventToLocalTime( $events ) {
        $localTZName = get_option('timezone_string');
        // All of our offset operations are in seconds
        $localOffset = get_option('gmt_offset') * 3600;
        // The timezone string can be empty if the timezone was set as a UTC offset,
        // in which case we will derive it from the offset.
        if('' == $localTZName) {
            $localTZName = timezone_name_from_abbr('', $localOffset, date('I'));
            // If we still couldn't obtain the local timezone then don't convert
            if(false === $localTZName) {
                return $events;
        $localTZ = new DateTimeZone($localTZName);
        foreach ($events as $event) {
            if (isset ($event['EventDate']) and (is_object ($event['EventDate']))) {
                $dt = $event['EventDate'];
                // Determine the time difference between the event timezone and
                // the local timezone. DateTime->getOffset returns the offset
                // in seconds, whereas the gmt_offset option is in hours.
                $secondsToAdd = $dt->getOffset() - $localOffset;
                $interval = new DateInterval('PT'.abs($secondsToAdd).'S');
                // Change the timezone. This will NOT change the UTC time.
                // Adjust the UTC time so that the relative time is the same.
                $secondsToAdd > 0 ? $dt->add($interval) : $dt->sub($interval);
        return $events;
    add_filter( 'amr_events_after_sort', 'ConvertEventToLocalTime' );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display event dates using event timezone?’ is closed to new replies.