[js] poprawka


(Jarek21 1992) #1

Witam,

Czy mógłby mi powiedzieć i pokazać jak zmienić w tym skrypcie funkcję, tak, aby odliczanie czasu trwało krócej?

Oto kod:

function startTimer() {

  var serverTime = getTime(document.getElementById("serverTime"));

  timeDiff = serverTime-1

  timeStart = serverTime;


  var spans = document.getElementsByTagName("span");

  for(var span_id in spans) {

    var span = spans[span_id];

    if(span.className == "timer" || span.className == "timer_replace") {

      startTime = getTime(span);

      if(startTime != -1)

        addTimer(span, serverTime+startTime, (span.className == "timer"));

    }

  }

(@Marcin) #2

Może coś takiego?

http://miramardesign.com/php-tutorials- ... -clock.htm

http://www.javascriptkit.com/script/scr ... time.shtml

http://forum.php.pl/index.php?showtopic=43234

albo

var serverTime = new Date(); serverTime.setTime(1190123116000); function updateTime() { serverTime.setTime(serverTime.getTime()+1000); displayTime(); } setInterval('updateTime()',1000); function to2Digit(n) { return (n<10)?('0'+n):(n); } function displayTime() { str = serverTime.getDate()+'. '+(serverTime.getMonth()+1)+'. '+serverTime.getFullYear()+' | '+serverTime.getHours()+':'+to2Digit(serverTime.getMinutes())+':'+to2Digit(serverTime.getSeconds()); obj = document.getElementById('serverTime'); obj.innerHTML = str; }