Synchronizing with server time - jquery countdown plugin and php -
i have following code in php file:
<div id="clocktimestamp" class="hidden"><?=$_server['request_time'];?></div> <div id="clock"></div>
i using jquery countdown plugin keith wood , calling this:
$('#countdown').countdown({until: until, serversync: getservertime});
and following code in js file:
function getservertime() { var time = $('#clocktimestamp').html()*1000; time = new date(time); return time; }
now, question is: approach $_server['request_time'] ok or should this:
function getservertime() { var time = null; $.ajax( { url: '../../_ajax/getservertime.php', async: false, datatype: 'text', success: function(text) { time = new date(text); }, error: function(http, message, exc) { time = new date(); } }); return time; }
i'm sure you've solved now, later visitors....
the easiest way use jquery server time plugin
Comments
Post a Comment