-
Notifications
You must be signed in to change notification settings - Fork 0
/
count.html
33 lines (31 loc) · 1.3 KB
/
count.html
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
<!DOCTYPE html>
<body>
<h2 id='remaining'></h2>
<script>
function datesUntilXmas() {
let now = new Date();// 객체 생성 부분
let newYear = new Date('December 25,' + (now.getFullYear()));
let diff = newYear - now;
let milliseconds = Math.floor(diff % 1000);
diff = diff / 1000;
let seconds = Math.floor(diff % 60);
diff = diff / 60;
let minutes = Math.floor(diff % 60);
diff = diff / 60;
let hours = Math.floor(diff % 24);
diff = diff / 24;
let days = Math.floor(diff);
let outStr = '금년 크리스마스까지 ' + days + '일, ' + hours + '시간, '
+ minutes;
outStr += '분, ' + seconds + '초' + ' 남았습니다.';
document.getElementById("remaining").innerHTML = outStr;
//작성부분
// 1초가 지나면 다시 함수를 호출한다.
setTimeout("datesUntilXmas()", 1000);
}
// 타이머를 시작한다.
//함수 실행 코드 작성부분
datesUntilXmas();
</script>
</body>
</html>