I am using Keith Woods countdown timer (http://keith-wood.name/countdown.html) with the serverSync function. This seems to work great in a single country however when I check the countdown from a different country it seems there is 15 hours ish difference.
So in Australia the countdown shows 1 day but in the US it shows 1 day 15 hours. I have implemented the server side code exactly as explained on the site but there is still the time difference. If I change my local clock it changes the countdown time but when hit refresh the countdown shows the correct amount of time so I know its getting the server time. However in the US there is still the time difference.
Any ideas why this could be if its reading the server time?
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
});
});
You have to deal with timezone issues yourself. Countdown will automatically apply these settings according to the docs:
So the client’s timezone is taken into account, as the script is loaded based on the client’s settings.
Edit with more:
Without knowing your exact code I can’t be sure, but you should be setting this to GMT and then offsetting to your server time once, rather than setting it to your server time which solves the problem of offsetting to each timezone automatically, which you don’t want. So use until: