kevincdaughtry

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • kevincdaughtry
    Participant

    cfcpca, you may also test date_default_timezone_get() instead of setting the timezone to get_option(‘timezone_string’). In my case get_option(‘timezone_string’) worked but date_default_timezone_get() is probably more generic. But it does depend on if we are dealing with the same issue as well.

    I also posted here, and there has been some conversation of a patch:
    https://theeventscalendar.com/support/forums/topic/recurring-event-times-error/#post-651730

    in reply to: Recurring Event Times Error #651730
    kevincdaughtry
    Participant

    Thanks Barry! And after thinking it over more get_option(‘timezone_string’) probably isn’t the best thing to convert the timezone to, because it assumes the timezone has been set to the timezone select in the WP Settings. Probably date_default_timezone_get() would be more generic.

    Thanks again for taking the time to respond!.

    in reply to: Recurring Event Times Error #650731
    kevincdaughtry
    Participant

    Barry,

    I completely agree with your statement on hacking core plugin code, and I was reluctant to do so. However there didn’t appear to be another simple fix. Making a simple change to Series Engine to fix this issue would further complicate it by breaking Series Engine and I didn’t see a way to fix this without touching a plugins core code.

    I also agree that you are reasonable to assume that the timezone will be UTC, and you are doing everything according to WordPress standards. However as you mentioned Series Engine does not appear to be the only plugin/theme that is not following those standards. And if it’s possible for you to add a couple lines of code to fix the issue (whether it’s the ones I provided or not) it would be very much appreciated by your customers. I have also seen other posts on this same topic, so in the long run I would imagine it would be beneficial for your support team and the satisfaction of your customers to resolve this issue, even if you’re not to blame.

    I appreciate all of your help!

    in reply to: Recurring Event Times Error #641833
    kevincdaughtry
    Participant

    I believe I found the issue and a solution.

    Series Engine was changing the default timezone to the one selected in my WP Settings (which was not UTC). Everything works fine for a single event because the date/time for the event is saved in the database and returned all in the default timezone, whatever that may be. When it comes to a recurring event the Events Calendar Pro plugin converts the date/time of the future events to a timestamp, which automatically converts to UTC and adjusts the time. The times then stay in UTC and are ouput as UTC as well, which causes the adjusted time. I was able to fix it by adding the follow code:

    // Fix for start date
    $this->start_date->setTimezone(new DateTimeZone(get_option(‘timezone_string’)));

    This goes in lib/tribeeventspro-recurrenceinstance.php inside the TribeEventsPro_RecurrenceInstance::__construct() method right after the line:
    $this->start_date = new DateTime(‘@’.$start_date);

    // Fix for end date
    $end_date->setTimezone(new DateTimeZone(get_option(‘timezone_string’)));

    This also goes in lib/tribeeventspro-recurrenceinstance.php inside the TribeEventsPro_RecurrenceInstance::save() method right after the line:
    $end_date = $this->get_end_date();

    kevincdaughtry
    Participant

    I just came across a similar issue and was able to track it down to a plugin I had installed that was using the php function date_default_timezone_set().

    Normally WordPress does everything in UTC and the Events Calendar Pro plugin works fine. But this other plugin was changing the default timezone to the one selected in my WP Settings (which was not UTC). Everything works fine for a single event because the date/time for the event is saved in the database and returned all in the default timezone, whatever that may be. When it comes to a recurring event the Events Calendar Pro plugin converts the date/time of the future events to a timestamp, which automatically converts to UTC and adjusts the time. The times then stay in UTC and are ouput as UTC as well, which causes the adjusted time. I was able to fix it by adding the follow code:

    // Fix for start date
    $this->start_date->setTimezone(new DateTimeZone(get_option(‘timezone_string’)));

    This goes in lib/tribeeventspro-recurrenceinstance.php inside the TribeEventsPro_RecurrenceInstance::__construct() method right after the line:
    $this->start_date = new DateTime(‘@’.$start_date);

    // Fix for end date
    $end_date->setTimezone(new DateTimeZone(get_option(‘timezone_string’)));

    This also goes in lib/tribeeventspro-recurrenceinstance.php inside the TribeEventsPro_RecurrenceInstance::save() method right after the line:
    $end_date = $this->get_end_date()

    I hope this helps!

Viewing 5 posts - 1 through 5 (of 5 total)