Thursday 15 July 2010

php - Jquery show server time -


The clock in my site is showing the server bar (on) sometimes it stops working, and so on It seems that they make page runs and slow down. The best way to do this is:

PHP:

    

Junkies:

  & lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {function show_clock () {$ .ajax ({type: 'POST', url: '/clock.php', timeout: 1000, success: function (data) {$ (" #servertime ") .html (data); window.setTimeout (show_clock, 1000);},}}}} show_clock ();}); & Lt; / Script & gt;   

Edit: This code is also tired, but it's also not right:

  & lt; Script type = "text / javascript" & gt; Var current time = '& lt;? Print Date ("FD, YH: I: S", Time ())? & Gt; // To obtain the PHP method for the date of the server var serverdate = new date (currenttime) function padlength (what) {var output = (what.toString (). Length == 1)? "0" + what: return output} function display time () {serverdate.setSeconds (serverdate.getSeconds () + 1) var timings = padleneth (serverdate.getHours ()) + ":" + padlength (serverdate.getMinutes ( )) Document.getElementById ("servertime"). InnerHTML = Timestream} setInterval ("displaytime ()", 1000) & lt; / Script & gt;    

Why not get server time when the page loads and then only the customer side Every moment grows? Any way server side time is actually going to give an exact version of what it is though.

No comments:

Post a Comment