﻿// JScript File

<!-- Paste this code into an external JavaScript file named: timeFormat.js  -->

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Sandeep Gangadharan :: http://www.sivamdesign.com/scripts/ */

function formatTime() {
  now = new Date();
  hour = now.getHours();
  min = now.getMinutes();
  sec = now.getSeconds();
  //if (document.getElementbyID("sivamtime")[0].checked) 
  {
    if (min <= 9) {
      min = "0" + min;
    }
    if (sec <= 9) {
      sec = "0" + sec;
    }
    if (hour > 12) {
      hour = hour;
      add = " PM";
    } else {
      hour = hour;
      add = " AM";
    }
    if (hour == 12) {
      add = " PM";
    }
    if (hour == 00) {
      hour = "12";
    }
    if(document.all) {
		document.getElementById("time").innerText = ((hour<=9) ? "0" + hour : hour) + ":" + min + ":" + sec;
	} 
	else {
		document.getElementById("time").textContent = ((hour<=9) ? "0" + hour : hour) + ":" + min + ":" + sec;
	}
  }
 setTimeout("formatTime()", 1000); 
}
