How to combine both javascripts to include ajax call for a server time instead of user time? -


i struggling how combine , make ajax call check server time upon loading javascript time server time , not client time ? need call time.php because page (where javascript located) doesn't use php , static, need @ way .. appreciate really!

ajax function call script time():

  $.fn.jclock.getserveroffset = function(el) {     //want make synchronous call server server time.     $.ajax({         url: "time.php",         async: false,         context: el,         success: function(result) {             var serverdate = new date(+(result) * 1000); //convert seconds number, , multiple 1000 milliseconds.             var clientdate = new date();              $this = $(this.context[0]);              $this.serveroffset = clientdate - serverdate; //set offset between server , client. } }); }; 

and countdown timer function ... must edit first new date() have no idea. please give me clue how may it?

javascript countdown timer:

<script> var currday = new date(); var day = currdate.getday(); var hrs = currdate.gethours(); var hrs0 = currdate.gethours(); var hrs00 = currdate.gethours(); var mins = currdate.getminutes(); var secs = currdate.getseconds(); var cswday = 7; var cswhrs = 19; var fthrs1 = 6; var fthrs2 = 14; var fthrs3 = 22; var bdwhrs1 = 5; var bdwhrs2 = 11; var bdwhrs3 = 17; var bdwhrs4 = 23; var ftmins1 = 59; var ftsecs1 = 60; var hrsout = 0; var hrsout2 = 0;  var hrs1 = fthrs1 - hrs; var hrs2 = fthrs2 - hrs; var hrs3 = fthrs3 - hrs;  var hrs01 = bdwhrs1 - hrs0; var hrs02 = bdwhrs2 - hrs0; var hrs03 = bdwhrs3 - hrs0; var hrs04 = bdwhrs4 - hrs0;  var day = cswday - day; var hrs001 = cswhrs - hrs00;  if (day == 7)     day = 0;  if ((hrs > 22) || ((hrs >= 0) && (hrs < 7))) {     if (hrs > 22)         hrsout = 7;     else         hrsout = hrs1; } if ((hrs > 6) && (hrs < 15))     hrsout = hrs2; if ((hrs > 14) && (hrs < 23))     hrsout = hrs3;  if ((hrs0 > 23) || ((hrs0 >= 0) && (hrs0 < 6))) {     if (hrs0 > 23)         hrsout2 = 6;     else         hrsout2 = hrs01; } if ((hrs0 > 5) && (hrs0 < 12))     hrsout2 = hrs02; if ((hrs0 > 11) && (hrs0 < 18))     hrsout2 = hrs03; if ((hrs0 > 17) && (hrs0 <= 23))     hrsout2 = hrs04;  mins = ftmins1 - mins; secs = ftsecs1 - secs;  var counter=setinterval(fttimer, 1000); var counter=setinterval(bdwtimer, 1000); var counter=setinterval(cswtimer, 1000); 

return date string php , create date variable in w3schools

and use jquery plugin explained @ jquery countdown

it has been reinventing have!

cheers.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -