jQuery.countdown
jQuery.countdown copied to clipboard
How should set since date or sync with server time?
Hi, a simple question...
There is a way to set the start date? There is some parameter as "since:" to set the server datetime (for server syncronization)? How could I do? Is it possible?
Thanks for a response!
Yes i also have same issue, need to sync it with server.
Ok, thanks!
+1, this really needs a "now" param to pass server time as the definitive time, otherwise the user's browser could be a long way out of sync.
Hello & thanks for this great plugin.
I have the same issue whereabouts the user fudges with their PC clock (e.g sets it an hour behind) and then the countdown becomes misleading.
Works well with different time zones but not when the local system time is tampered with.
Are you planning in the near future to provide an enhancement to this, i.e. to subtract the time remaining from an accurate date? Eg. a server date/time?
Cheers
Duplicated #119.
Even if does, it won't solve the problem because user always can screw with his machine date. The suggested approach is to make an AJAX call to some endpoint that retrieve the correct offset and reset the countdown!
var $clock = $("#clock").on('update.countdown', function(event) { /* ... */ });
// Sync with the server time
$.get("http://myhost.com/server-time", {userMachineDate: new Date()}, function(data) {
var serverTimeOffset = new Date(data);
$clock.countdown(serverTimeOffset);
});
But why we can't initialize plugin with remaining milliseconds instead of final date value? Remaining seconds we can get from server, local time shouldn't affect on countdown in this case.
@LordotU that's a nice idea!
@hilios your solutions is never work.
//get the remaining time from server side
//then set the endDate be equals to local time + remaining time;
//here's my solution
var remainingTime; //in milliseconds,get from server side
var endDate = new Date(Date.parse(new Date()) +remainingTime );
$(' .count_down').countdown(endDate ), function(event) {
// your code here
});
//get the remaining time from server side //then set the endDate be equals to local time + remaining time; //here's my solution var remainingTime; //in milliseconds,get from server side var endDate = new Date(Date.parse(new Date()) +remainingTime ); $(' .count_down').countdown(endDate ), function(event) { // your code here });
var endDate = Date.now() + remainingTime;