• Resolved af3

    (@af3)


    Hi, I realized that the next match countdown widget is not correcting to the user’s time but sticking to the server time. Is it just me or other are experiencing this?

    Change your pc time to something else and go to the site. The countdown should reflect (my local time – match time at my local time) but it is not. It is counting (my local time – match time fixed at server time). Time set in FP is using WordPress time.

    • This topic was modified 2 years, 4 months ago by af3.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author AntoineH

    (@antoineh)

    hi, unfortunately the widget and countdown shortcode do not support the user time in a different timezone setting than the website config. I will note it down for the future to see if this can be changed.

    • This reply was modified 2 years, 4 months ago by AntoineH.
    Thread Starter af3

    (@af3)

    Thanks Antoine. Maybe can use javascript to populate a session that has the user timezone and call in php that session data to calculate the countdown? Anyway i dont know hpw to do this ;(

    Thread Starter af3

    (@af3)

    Antoine
    I added this js in header.php of my theme:

    <script type="text/javascript">
    	<!--  Get the user timezone -->
    	var timezone_offset_minutes = new Date().getTimezoneOffset();
    	timezone_offset_minutes = timezone_offset_minutes == 0 ? 0 : -timezone_offset_minutes;
    	<!-- Timezone difference in minutes such as 330 or -360 or 0 -->
    	console.log(timezone_offset_minutes); 
    	</script>
    

    And made this function inside class-football-pool-utils.php like this:

    
    public static function date_from_gmt( $date_string, $date_format = 'Y-m-d H:i' ) {
            $timezone_offset_minutes = $_GET['timezone_offset_minutes'];
            // Convert minutes to seconds
            $timezone_name = timezone_name_from_abbr("", $timezone_offset_minutes*60, false);
            date_default_timezone_set($timezone_name);
    	if ( strlen( $date_string ) === strlen( '0000-00-00 00:00' ) ) $date_string .= ':00';
    	return $date_string !== '' ? get_date_from_gmt( $date_string, $date_format ) : '';
    	}
    

    Not sure if this is the best but seems like the countdown changes based on my pc’s timezone.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Next Match widget time is off’ is closed to new replies.