자바스크립트로 만든 시계
시간(clock) 자바스크립트
js
function MakeArrayday(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function MakeArraymonth(size) {
this.length = size;
for(var i = 1; i <= size; i++) {
this[i] = "";
}
return this;
}
function funClock() {
var runTime = new Date();
var years = runTime.getFullYear();
var months = runTime.getMonth()+1;
var days = runTime.getDate();
var hours = runTime.getHours();
var minutes = runTime.getMinutes();
var seconds = runTime.getSeconds();
if (hours >= 12) {
hours = hours - 12;
}
if (hours == 0) {
hours = 12;
}
if (minutes <= 9) {
minutes = "0" + minutes;
}
if (seconds <= 9) {
seconds = "0" + seconds;
}
movingtime = years+ "/" + months + "/" + days + " " + hours + ":" + minutes + ":" + seconds ;
document.getElementById('clock').innerHTML = movingtime;
setTimeout("funClock()", 1000)
}
window.onload = funClock;
html
<span id=clock> </span>
CodePen
See the Pen javascript로 만든 clock by younghyeong ryu (@wangta69) on CodePen.