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 | <!DOCTYPE html> <html> <head> <meta charset="EUC-KR"> <title> 현재시간 </title> </head> <body onload="showClock()"> <div id="divClock" class="clock"> </div> </body> <script type="text/javascript"> function showClock() { var currentDate = new Date(); var divClock = document.getElementById("divClock"); var msg = "현재 시간: " + currentDate.getHours()+"시 " msg += currentDate.getMinutes() + "분 "; msg += currentDate.getSeconds() + "초 "; if (currentDate.getHours() >=12) { msg +="PM"; }else{ msg +="AM"; } divClock.innerText = msg; setTimeout(showClock, 1000); } </script> </html> | cs |
'프로그래밍 > WEB' 카테고리의 다른 글
HTML5 + CSS3 + Javascript 웹프로그래밍 chapter2 연습문제 (0) | 2020.10.20 |
---|---|
HTML5 + CSS3 + Javascript 웹프로그래밍 chapter1 연습문제 (0) | 2020.10.20 |
MVC (0) | 2019.03.19 |
[html&css&js]회원가입 유효성검사 (0) | 2018.10.21 |
[HTML]div, span 의 차이점 (0) | 2018.10.18 |