I’m using this javascript code in order to calculate the difference between the current time and targeted time.
the counter is working fine, but according to client time, not Server side time.
Here is the code I’m using:
function StartCountDown(myDiv,myTargetDate)
{
var dthen = new Date(myTargetDate);
var dnow = new Date();
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(myDiv,gsecs);
}
how to get the server time, not client local machine time?
You could echo the time as an php function to your script
or any date/time format you like. But then of course this would only get server time when page is first loaded. You coud try an appoach like here: http://www.roseindia.net/ajax/jquery/jqueryservertime.shtml to load the time with ajax to your page.