• Resolved magicca

    (@magicca)


    Hi, first of all, thank you very much for this very helpful plugin!
    I do have a problem though.
    As you may notice, we should setup the same time zone for local(computer) and server, otherwise, we will get some missed schedule posts.
    When I setup the timezone of my Computer/Server/WordPress the same as my local time (which is UTC-8,Los Angeles, US), Auto Post Scheduler will display a kind of weird time(8 hour behind my timezone, = UTC-16, actually no such timezone) and won’t work on schedule time, of course.
    Everything is fine when I setup all timezones (Computer/Server/WordPress) to UTC, but I prefer to use my local time instead of UTC time, if it’s possible.
    Please advise. Thanks.

    https://www.ads-software.com/plugins/auto-post-scheduler/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author johnh10

    (@johnh10)

    Hello,
    APS uses the current local time of the server and the Timezone set in WordPress->Settings->General.

    When you enable APS what does it display at the top? It should be something like

    Current Status: Enabled

    Current server time:2014-12-22 09:29:28 America/New_York
    Next auto post check:2014-12-22 10:28:50 America/New_York

    Thread Starter magicca

    (@magicca)

    Hi, Thanks for your reply.
    There are 3 places setup timezone: 1)server, 2)wp_settings.php, 3)WordPress->Settings->General.
    When I change number 2 (via my theme function, of course. It’s not a good idea to touch the WP core, right?) to my timezone by
    date_default_timezone_set( 'America/Los_Angeles' );
    Auto Post Scheduler will display the weird time, 8 hour behind my timezone.
    I tested this all the day to make sure. see table below(yes=correct, no=wrong):

    Server:      LA    LA     UTC    UTC
    WP_settings: LA    UTC    LA     UTC
    WP option:   LA    LA     LA     LA
    APS:         NO    YES    NO     YES

    Plugin Author johnh10

    (@johnh10)

    Why would you need to change wp_settings.php? Sounds like it is converting the timezone offset twice. Try it without.

    APS gets the local time via the WordPress function
    current_time(“timestamp”)

    Plugin Author johnh10

    (@johnh10)

    Yes it looks like double dipping when you call date_default_timezone_set() in your code.

    Added this to functions.php to test

    function heartbeat_debug() {
            error_log('Local Time: ' . date('Y-m-d H:i:s',current_time("timestamp")) . " " . get_option('timezone_string'));
            error_log('GMT Time: ' . date('Y-m-d H:i:s',current_time("timestamp", 1)) . " GMT" );
    
            date_default_timezone_set( 'America/New_York' );
            error_log('calling date_default_timezone_set');
            error_log('Local Time: ' . date('Y-m-d H:i:s',current_time("timestamp")) . " " . get_option('timezone_string'));
            error_log('GMT Time: ' . date('Y-m-d H:i:s',current_time("timestamp", 1)) . " GMT" );
    }
    
    add_action('wp_head', 'heartbeat_debug');

    Outputs:
    [23-Dec-2014 15:16:50 UTC] Local Time: 2014-12-23 10:16:50 America/New_York
    [23-Dec-2014 15:16:50 UTC] GMT Time: 2014-12-23 15:16:50 GMT
    [23-Dec-2014 10:16:50 America/New_York] calling date_default_timezone_set
    [23-Dec-2014 10:16:50 America/New_York] Local Time: 2014-12-23 05:16:50 America/New_York
    [23-Dec-2014 10:16:50 America/New_York] GMT Time: 2014-12-23 10:16:50 GMT

    Thread Starter magicca

    (@magicca)

    >Why would you need to change wp_settings.php?
    Same timezone as my local computer.

    >Sounds like it is converting the timezone offset twice.
    Exactly.

    Plugin Author johnh10

    (@johnh10)

    That’s what WordPress->Settings->General->Timezone is for.

    Thread Starter magicca

    (@magicca)

    Never mind.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Problem with timezone’ is closed to new replies.