我正在使用Keith Woods倒數計時器(http://keith-wood.name/countdown.html)和serverSync函數。這似乎在一個國家效果很好,但是當我檢查來自不同國家的倒計時時,看起來有15小時不同。jQuery倒計時serverSync 15小時差
所以在澳大利亞倒計時顯示1天,但在美國顯示1天15小時。我完全按照網站上的說明實施了服務器端代碼,但仍然存在時差。如果我更改本地時鐘,它會更改倒計時時間,但當點擊刷新時,倒計時會顯示正確的時間量,以便我知道它獲取服務器時間。然而在美國仍然存在時差。
任何想法,爲什麼這可能是如果它讀取服務器時間?
function serverTime() {
var time = null;
$.ajax({url: 'server-time.php?random=' + Math.floor(Math.random() * 1000000),
async: false,
dataType: 'text',
success: function(text) {
time = new Date(text);
}, error: function(http, message, exc) {
time = new Date();
}});
return time;
}
var launchDate = "";
$(function() {
launchDate = new Date(
2012,
5-1,
22,
11
);
$('#launchCountdown').countdown('destroy')
$('#launchCountdown').countdown({
until: launchDate,
serverSync: serverTime,
format: 'DHMS',
expiryText: '<p>It\'s all over</p>'
//onTick: highlightLast5
});
});
謝謝。我之前從未使用UTCDate,所以沒有真正知道這是什麼。 – puks1978