From 17522e208554ce53c7846a6083ffbd32c63529ee Mon Sep 17 00:00:00 2001 From: Nabil Kadimi Date: Wed, 13 Mar 2019 13:48:16 +0000 Subject: [PATCH] Fix timezone handling in countdowns --- assets/js/sportspress.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/assets/js/sportspress.js b/assets/js/sportspress.js index cfef48c3..4ab94b28 100644 --- a/assets/js/sportspress.js +++ b/assets/js/sportspress.js @@ -21,16 +21,9 @@ function sp_viewport() { var countDownDate = new Date($(this).data('countdown')).getTime(); // Iterate every second var x = setInterval(function() { - - // Get todays date and time - var now = new Date(); - - // Convert curent date and time to UTC - var tzDifference = now.getTimezoneOffset(); - var nowutc = new Date(now.getTime() + tzDifference * 60 * 1000); - + // Find the distance between now and the count down date - var distance = countDownDate - nowutc; + var distance = countDownDate - (new Date); if ( distance < 0 ) { distance = 0; } @@ -116,4 +109,4 @@ function sp_viewport() { } }); -})(jQuery); \ No newline at end of file +})(jQuery);