Else/- Computer

상태바에 현재 날짜와 시간 나타내기

unisty 2004. 12. 9. 12:19
스크립트 소스.

<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<script language="JavaScript">
<!--
var timerID = null
var timerRunning = false
function MakeArray(size) {
        this.length = size;
        for(var i = 1; i <= size; i++) {
                this[i] = "";
        }
        return this;
}
function stopclock () {
        if(timerRunning)
        clearTimeout(timerID);
        timerRunning = false
}
function showtime () {
        var now = new Date();
        var year = now.getYear();
        var month = now.getMonth() + 1;
        var date = now.getDate();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds();
        var day = now.getDay();
        Day = new MakeArray(7);
        Day[0]="일요일";
        Day[1]="월요일";
        Day[2]="화요일";
        Day[3]="수요일";
        Day[4]="목요일";
        Day[5]="금요일";
        Day[6]="토요일";
        var timeValue = "";

        timeValue += year + "년" + ((month > 10) ? " " : " ") + month + "월 ";        
        timeValue += date + "일 ";
        timeValue += (Day[day]) + "  ";
        timeValue += (hours > 12) ? " 오후 " : " 오전 ";        
        timeValue += ((hours <= 12) ? hours : hours - 12);
        timeValue += ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
        timeValue += ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
        
        window.status = timeValue;
        timerID = setTimeout("showtime()",1000);
        timerRunning = true
        }
function startclock () {
        stopclock();
        showtime()
}
// -->
</script>