What time is it?
document.getElementsByTagName("div")[0].style.marginTop = document.height / 3 + "px";
window.setInterval(function () {
var time = "";
var now = new Date();
var hours = "" + now.getHours() + ":";
var minutes = "" + now.getMinutes() + ":";
var seconds = "" + now.getSeconds();
var part;
if (parseInt(hours) < 12) {
part = " AM";
} else {
hours = parseInt(hours);
if (hours !== 12) {
hours -= 12;
}
hours += ":";
part = " PM";
}
if (hours.length < 3) {
hours = "0" + hours;
}
if (minutes.length < 3) {
minutes = "0" + minutes;
}
if (seconds.length < 2) {
seconds = "0" + seconds;
}
time += hours;
time += minutes;
time += seconds;
time += part;
document.getElementById("holder").innerHTML = time;
}, 1000);
div {
text-align: center;
font-size: 100pt;70pt;
}
<div id="holder"></div>
What time is it?
document.getElementsByTagName("div")[0].style.marginTop = document.height / 3 + "px";
window.setInterval(function () {
var time = "";
var now = new Date();
var hours = "" + now.getHours() + ":";
var minutes = "" + now.getMinutes() + ":";
var seconds = "" + now.getSeconds();
var part;
if (parseInt(hours) < 12) {
part = " AM";
} else {
hours = parseInt(hours);
if (hours !== 12) {
hours -= 12;
}
hours += ":";
part = " PM";
}
if (hours.length < 3) {
hours = "0" + hours;
}
if (minutes.length < 3) {
minutes = "0" + minutes;
}
if (seconds.length < 2) {
seconds = "0" + seconds;
}
time += hours;
time += minutes;
time += seconds;
time += part;
document.getElementById("holder").innerHTML = time;
}, 1000);
div {
text-align: center;
font-size: 100pt;
}
<div id="holder"></div>
What time is it?
document.getElementsByTagName("div")[0].style.marginTop = document.height / 3 + "px";
window.setInterval(function () {
var time = "";
var now = new Date();
var hours = "" + now.getHours() + ":";
var minutes = "" + now.getMinutes() + ":";
var seconds = "" + now.getSeconds();
var part;
if (parseInt(hours) < 12) {
part = " AM";
} else {
hours = parseInt(hours);
if (hours !== 12) {
hours -= 12;
}
hours += ":";
part = " PM";
}
if (hours.length < 3) {
hours = "0" + hours;
}
if (minutes.length < 3) {
minutes = "0" + minutes;
}
if (seconds.length < 2) {
seconds = "0" + seconds;
}
time += hours;
time += minutes;
time += seconds;
time += part;
document.getElementById("holder").innerHTML = time;
}, 1000);
div {
text-align: center;
font-size: 70pt;
}
<div id="holder"></div>