Support » Plugin: My Calendar » Times in event change when saved, don’t match calendar

  • Resolved redkite

    (@redkite)


    We saved this linked test event with times of 8:30 am to 9:30 am. When it saves it changed immediately to 8:30 pm to 3:30 pm, which is wrong, but even this is not displayed on the calendar. It shows 2:30 am to 9:30 pm on the calendar and popup. What is going on here with these mismatched times??

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Joe Dolson

    (@joedolson)

    That sounds like a timezone offset; are you on the latest version of My Calendar? Is the timezone configured for your site correct?

    redkite

    (@redkite)

    My Calendar version 3.2.1 and our timezone is correct, UTC -6.

    Plugin Author Joe Dolson

    (@joedolson)

    It’s definitely curious, but the changes are in multiples of 6, so I am guessing it’s relative to your timezone in some way – although the cause isn’t clear to me yet.

    I think I’ll need more information to solve this; I can’t recreate it, but I know that I *did* have this issue at one point during development on 3.2.0, but fixed it.

    What timezone is your server set for? (Not WordPress; the server itself.)

    redkite

    (@redkite)

    It’s EDT.

    Plugin Author Joe Dolson

    (@joedolson)

    Are there any other calendar applications or plugins that manage time installed on your site?

    redkite

    (@redkite)

    There was another calendar plugin but I removed that on Monday or Tuesday. I just confirmed that the weird time shift is still happening.

    There was another one called Post Expirator. I just disabled that one but the problem still persists in My Calendar. This is really a mystery…

    There’s also Jetpack, not sure if that might be related to time management. But disabling it didn’t help.

    redkite

    (@redkite)

    Okay – it’s a theme issue. I made a staging copy and deactivated all plugins, no change. Switched to two different default themes, that fixed it.

    What can I look for in the theme itself that may be a culprit? I built the theme (it’s based on Theme Hybrid) around 2017. But this problem is relatively recent, it started happening earlier this year.

    Plugin Author Joe Dolson

    (@joedolson)

    Does your theme use the function date_default_timezone_set() or anything similar?

    That’s not a function I’d normally expect in a theme, but it *is* a function that can cause problems with dates.

    WordPress made a lot of changes to the core time/date functions in version 5.3, released in November 2019, so it probably stems from those – often because prior to 5.3, plugins & themes employed a wide variety of workarounds to deal with some of the oddities in the core WordPress date/time functions.

    redkite

    (@redkite)

    That’s it! There was a function to replace the ‘howdy’ greeting that used date_default_timezone_set(), I changed it to current_datetime() and it seems to be fine now.

    Thanks for helping me troubleshoot this!

    mdegive

    (@mdegive)

    I have the same issue since I upgraded to 3.2.0/3.2.1

    I searched for date_default_timezone_set and it is used in wp-settings.php:
    date_default_timezone_set( ‘UTC’ );

    And it is also in wp-admin\options-general.php

    When I set a date on an event to July 1st 5PM to 7PM, after save it becomes July 1st 2PM to 9AM, and the calendar displays it on July 2nd 4am.

    date_default_timezone_set is NOT anywhere in my theme.

    WP Version: 5.4.2, PHP Version: 5.6.38

    Help, my calendar is now broken!

    Plugin Author Joe Dolson

    (@joedolson)

    There shouldn’t be an occurrence of date_default_timezone_set in options-general.php; can you give me more info about that?

    options-general.php:
    line 183
    // Set TZ so localtime works.
    date_default_timezone_set($tzstring);
    $now = localtime(time(), true);
    line 218
    // Set back to UTC.
    date_default_timezone_set(‘UTC’);

    Plugin Author Joe Dolson

    (@joedolson)

    Then that sounds like your version of WordPress has been modified; that is *not* code that’s supposed to be in that file.

    This is line 183 of wp-admin/options.general.php in WordPress 5.4.2:

    https://github.com/WordPress/WordPress/blob/5.4.2/wp-admin/options-general.php#L183

    My bad, I was looking at an older copy of that script on my local machine, it is fine on the server.

    Now the only occurrences are in:
    wp-admin/includes/class-wp-site-health.php line 1070 section

    and in wp-includes/class-phpmailer.php line 3297

    So how can we fix this?

    Plugin Author Joe Dolson

    (@joedolson)

    Have you tried disabling plug-ins and switching themes to see if there’s a conflict with one of those?

Viewing 15 replies - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.