часы - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of часы.php

  1. <!DOCTYPE HTML>
  2.  
  3. <html>
  4.  
  5. <head>
  6.   <title>Untitled</title>
  7.   <meta charset="utf-8">
  8.   <style type="text/css">
  9.   .time{
  10.     color: rgb(102, 255, 255);
  11.      background-color: rgb(0, 0, 255);
  12.      padding: 2px 4px;
  13.      border-radius: 4px;
  14.      display: flex;
  15.      width: 50px;
  16.      justify-content:  space-between;
  17.   }
  18.  
  19.   .time span{
  20.     margin: 2px;
  21.     font-weight: bold;
  22.     text-align: center;
  23.   }
  24.   .time .sp, .time .spl{
  25.     color: rgb(255, 255, 255);
  26.     font-size: 20px;
  27.   }
  28.   .sec {
  29.     color: rgb(255, 255, 0);
  30.   }
  31.   .time .sp{
  32.       margin: -1px;
  33.   }
  34.  
  35.   </style>
  36. </head>
  37.  
  38. <body>
  39.   <span class="time"></span><br>
  40.                      
  41. <script>
  42.  
  43. function fn(f, a) {
  44.     var c = {
  45.         cls: ["hour", "sp", "min"],
  46.         formatTime: function(b) {
  47.             b = Math.floor(b / 1E3);
  48.             var a = Math.floor(b / 60),
  49.                 d = Math.floor(a / 60);
  50.             b %= 60;
  51.             a %= 60;
  52.             var t = b % 2 ? ":" : "\u200A";
  53.             return [c.two(d % 24), t, c.two(a)]
  54.         },
  55.         two: function(b) {
  56.             return (9 < b ? "" : "0") + b
  57.         },
  58.         timer: function(b) {
  59.             var a = performance.now();
  60.             requestAnimationFrame(function g(e) {
  61.                 e -= a;
  62.                 e = c.formatTime(b + e);
  63.                 c.cls.forEach(function(a, b) {
  64.                     a.innerHTML = e[b]
  65.                 });
  66.                 requestAnimationFrame(g)
  67.             })
  68.         },
  69.         init: function() {
  70.             a = a.split(":");
  71.             a = 36E5 * a[0] + 6E4 * a[1] + 1E3 * a[2];
  72.             c.cls = c.cls.map(function(a) {
  73.                 var d = document.createElement("span");
  74.                 d.classList.add(a);
  75.                 f.appendChild(d);
  76.                 return d
  77.             });
  78.             c.timer(a)
  79.         }
  80.     };
  81.     c.init()
  82. };
  83.  
  84.  
  85. var span = document.querySelector('.time') ;
  86. fn(span, '<?php echo date("G").":".date("i").":".date("s"); ?>');
  87. </script>
  88.  
  89. </body>
  90. </html>
  91.  
File Description
  • часы
  • PHP Code
  • 07 Apr-2021
  • 2.02 Kb
You can Share it: