Показать сообщение отдельно
  #13 (permalink)  
Старый 13.11.2015, 02:39
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,072

часы по времени сервера

убрал лишнее
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
  .time{
    color: rgb(102, 255, 255);
     background-color: rgb(0, 0, 255);
     padding: 2px 4px;
     border-radius: 4px;
  }

  .time span{
    margin: 2px;
    font-weight: bold;
  }
  .time .sp, .time .spl{
    color: rgb(255, 255, 255);
    font-size: 20px;
  }
  .sec {
    color: rgb(255, 255, 0);
  }

  </style>
</head>

<body>
  <span class="time"></span><br>

<script>

function fn(f, a) {
    var c = {
        cls: ["hour", "sp", "min", "spl", "sec"],
        formatTime: function(b) {
            b = Math.floor(b / 1E3);
            var a = Math.floor(b / 60),
                d = Math.floor(a / 60);
            b %= 60;
            a %= 60;
            return [c.two(d % 24), ":", c.two(a), ":", c.two(b)]
        },
        two: function(b) {
            return (9 < b ? "" : "0") + b
        },
        timer: function(b) {
            var a = performance.now();
            requestAnimationFrame(function g(e) {
                e -= a;
                e = c.formatTime(b + e);
                c.cls.forEach(function(a, b) {
                    a.innerHTML = e[b]
                });
                requestAnimationFrame(g)
            })
        },
        init: function() {
            a = a.split(":");
            a = 36E5 * a[0] + 6E4 * a[1] + 1E3 * a[2];
            c.cls = c.cls.map(function(a) {
                var d = document.createElement("span");
                d.classList.add(a);
                f.appendChild(d);
                return d
            });
            c.timer(a)
        }
    };
    c.init()
};


var span = document.querySelector('.time') ;
fn(span, '02:08:41');// fn(span, '%uptime%'); 
//fn(span, '<?php echo date("G").":".date("i").":".date("s"); ?>'); 
</script>

</body>
</html>

Последний раз редактировалось рони, 09.08.2019 в 15:41.
Ответить с цитированием