본문 바로가기
Developer/Javascript & jQuery

[Javascript] 동적현재시간2

by 순수한소년 2017. 1. 29.
728x90
반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<HTML>
<HEAD>
<STYLE>
#clock {
    position: absolute;
    left: 40;
    top: 20;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="#000033">
    <SPAN ID="clock"></SPAN>
    <SCRIPT LANGUAGE="JavaScript">
        function showTime() {
            var today = new Date();
            var hour = today.getHours();
            if (hour > 12) {
                hour = "오후 " + (hour - 12);
            } else {
                hour = "오전 " + hour;
            }
            var minute = today.getMinutes();
            if (minute < 10) {
                minute = "0" + minute;
            }
            var second = today.getSeconds();
            if (second < 10) {
                second = "0" + second;
            }
            var mytime = "<B><FONT SIZE=\"6\" COLOR=\"orange\">" + hour + ':' + minute + ':' + second + "</FONT></B>";
 
            if (document.layers) {
                document.clock.document.write(mytime);
                document.clock.document.close();
            } else if (document.all) {
                clock.innerHTML = mytime;
            }
        }
        setInterval("showTime()"1000);
    </SCRIPT>
</BODY>
</HTML>
cs
728x90
반응형