function tick() {
var years, months, days, hours, minutes, seconds, ap;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
years = today.getYear() + "-";
months = (today.getMonth() + 1) + "-";
days = today.getDate() + " ";
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
ap = "Midnight";
} else if (intHours < 12) {
hours = intHours+":";
ap = "A.M.";
} else if (intHours == 12) {
hours = "12:";
ap = "Noon";
} else {
hours = intHours + ":";
ap = "P.M.";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = years + months + days + hours + minutes + seconds + ap;
Clock.innerHTML = timeString;
//document.write(timeString);
window.setTimeout("tick();", 1000);
}
window.onload = tick;
var years, months, days, hours, minutes, seconds, ap;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
years = today.getYear() + "-";
months = (today.getMonth() + 1) + "-";
days = today.getDate() + " ";
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
ap = "Midnight";
} else if (intHours < 12) {
hours = intHours+":";
ap = "A.M.";
} else if (intHours == 12) {
hours = "12:";
ap = "Noon";
} else {
hours = intHours + ":";
ap = "P.M.";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = years + months + days + hours + minutes + seconds + ap;
Clock.innerHTML = timeString;
//document.write(timeString);
window.setTimeout("tick();", 1000);
}
window.onload = tick;
<span id="Clock"></span>