digital clock

<html>
  <body>
    <div id="MyClockDisplay" class="clock" onload="showTime()">
</div>
  </body>
  </html>
body{
  background-color: black;
}
.clock{
  position:absolute;
  top:50%;
  left:50%;
  transform:translateX(-50%) translateY(-50%);
  color:#17D4FE;
  font-size:60px;
  font-family:Orbitron;
  letter-spacing:7px;
}
function showTime(){
  var date=new Date();
  var h=date.getHours();
  var m=date.getMinutes();
  var s=date.getseconds();
  var session="AM";

  if(h==0){
    h=12;
  }
  if(h>12)
  {
    h=h-12;
    session="PM";
  }
  h=(h<10)?"0"+h:h;
  m=(m<10)?"0"+m:m;
  s=(s<10)?"0"+s:s;

  var time=h+":"+m+":"+s+""+session;
  document.getElementById("MyClockDisplay").innerText=time;
  document.getElementById("MyClockDisplay").textContent=time;
  setTimeout(showTime,1000);
}
showTime();

digital clock

  • Files
  • Index
  • Style
  • Script
  • README
  • CDN Add
HTML
PLEASE WAIT...