관리 메뉴

moozi

d-day 구하기 javascript 본문

TIS_2016/HTML5_1기

d-day 구하기 javascript

moozi 2016. 4. 4. 18:04

<html>

<head>

<meta charset="utf-8">

<script type="text/javascript">


function reverse_counter(){

today = new Date();

d_day = new Date("2018-02-09");

days = (d_day - today) / 1000 / 60 / 60 / 24;

daysRound = Math.floor(days);

hours = (d_day - today) / 1000 / 60 / 60 - (24 * daysRound);

hoursRound = Math.floor(hours);

minutes = (d_day - today) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);

minutesRound = Math.floor(minutes);

seconds = (d_day - today) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) -(60 * minutesRound);

secondsRound = Math.round(seconds);

sec = " 초.";

min = " 분, ";

hr = " 시간, ";

dy = " 일, ";

document.counter.counter_box.value = " 남은 시간 : " + daysRound +dy + hoursRound + hr + minutesRound + min + secondsRound + sec;

newtime = window.setTimeout("reverse_counter();", 1000);

}


</script>

</head>

<body onLoad="reverse_counter();">


<center>

<form name="counter">

<input type="text" name="counter_box" size="55" >

</form>

</center>

</body>

</html>



'TIS_2016 > HTML5_1기' 카테고리의 다른 글

달력 예제  (0) 2016.04.05
2차 포트폴리오  (13) 2016.04.05
부트스트랩에서 navbar 배경색 바꾸기  (0) 2016.04.04
4/2 slide javascript  (0) 2016.04.01
modal video fullscreen  (0) 2016.03.31
0 Comments
댓글쓰기 폼