Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter PhilipBarrington

    (@philipbarrington)

    I have tried this, and it seems ok, but I will need to watch it.

    The file I am editing is

    pcf-guy-fawkes-night-countdown/core/pcfcg-countdown.php

    The edits are in the two lines to replace $date with $date_i18n.
    My understanding of the difference is that $date is a php function which will return the utc date-time, whereas $date_i18n is a WordPress function which will return the current date-time of the WordPress Installation as set in the WordPress Settings area.

    <?php
    function pcfcg_calculate($day, $month, $year){
        $date_i18n = strtotime($day.'-'.$month.'-'.$year);
        $remaining = $date_i18n - time();

    Hope this helps.

    Thread Starter PhilipBarrington

    (@philipbarrington)

    Hi, sorry to report, I am not quite as good as I hoped, as that does not change the result.

    Thread Starter PhilipBarrington

    (@philipbarrington)

    I think I have now cracked this.

    The issue revolves around date time on the WordPress Install.

    The date functions should be as suggested $date_i18n

    The time should be current_time( ‘timestamp’ ) which gets the time from the wordpress install.

    function pcfcg_calculate($day, $month, $year){
    
     $date_i18n = strtotime($day.'-'.$month.'-'.$year);
    
     $remaining = $date_i18n - current_time( 'timestamp' );

    The benefit of this is that it then works in any timezone, because it counts down to the local time rather than to UTC.

    Hope it helps

    Thread Starter PhilipBarrington

    (@philipbarrington)

    On reviewing this further, I think the key issue is the $remaining formula which needs to reflect the timezone which the installation of WordPress is set up to reflect.

    $remaining = $date – current_time( ‘timestamp’ );

    This appears to be working for me,

    Thread Starter PhilipBarrington

    (@philipbarrington)

    No, I have no idea how to make it work, internationally.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Time Zone’ is closed to new replies.