Merge pull request #329 from kadimi/patch-5
Fix timezone handling in countdowns
This commit is contained in:
@@ -21,16 +21,9 @@ function sp_viewport() {
|
|||||||
var countDownDate = new Date($(this).data('countdown')).getTime();
|
var countDownDate = new Date($(this).data('countdown')).getTime();
|
||||||
// Iterate every second
|
// Iterate every second
|
||||||
var x = setInterval(function() {
|
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
|
// Find the distance between now and the count down date
|
||||||
var distance = countDownDate - nowutc;
|
var distance = countDownDate - (new Date);
|
||||||
if ( distance < 0 ) {
|
if ( distance < 0 ) {
|
||||||
distance = 0;
|
distance = 0;
|
||||||
}
|
}
|
||||||
@@ -116,4 +109,4 @@ function sp_viewport() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|||||||
Reference in New Issue
Block a user