Clock Out of Form

[Total: 0    Average: 0/5]

Bet you’re all tired of clocks in forms, right?

Body Code:

<div id="Clock" align="Center">&nbsp</div>

<script>
function tick() {
  var hours, minutes, seconds, ap;
  var intHours, intMinutes, intSeconds;
  var today;

  today = new Date();

  intHours = today.getHours();
  intMinutes = today.getMinutes();
  intSeconds = today.getSeconds();

  if (intHours == 0) {
     hours = "12:";
     ap = "A.M.";
  } else if (intHours < 12) { 
     hours = intHours+":";
     ap = "A.M.";
  } else if (intHours == 12) {
     hours = "12:";
     ap = "P.M.";
  } else {
     intHours = intHours - 12
     hours = intHours + ":";
     ap = "P.M.";
  }

  if (intMinutes < 10) {
     minutes = "0"+intMinutes+":";
  } else {
     minutes = intMinutes+":";
  }

  if (intSeconds < 10) {
     seconds = "0"+intSeconds+" ";
  } else {
     seconds = intSeconds+" ";
  } 

  timeString = hours+minutes+seconds+ap;

  Clock.innerHTML = timeString;

  window.setTimeout("tick();", 100);
}

window.onload = tick;

</script>
<p>A very nice Dynamic Clock. Uses &lt;div&gt;&lt;/div&gt;&nbsp;<br>
Updates every
second. Much better than version1.0</p>

Times Viewed: 2

Leave a Reply

Your email address will not be published. Required fields are marked *