남은시간 카운트하는 자바스크립트

· 2018-08-29 (수) 13:33:43 · 6902 · 1

<SCRIPT language=JavaScript> 

function getTime() { 

now = new Date(); 

dday = new Date(2013,02,14,18,00,00); 

// 원하는 날짜, 시간 정확하게 초단위까지 기입.

days = (dday - now) / 1000 / 60 / 60 / 24; 

daysRound = Math.floor(days); 

hours = (dday - now) / 1000 / 60 / 60 - (24 * daysRound); 

hoursRound = Math.floor(hours); 

minutes = (dday - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound); 

minutesRound = Math.floor(minutes); 

seconds = (dday - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound); 

secondsRound = Math.round(seconds); 

document.getElementById("counter1").innerHTML = hoursRound; 

document.getElementById("counter2").innerHTML = minutesRound; 

document.getElementById("counter3").innerHTML = secondsRound; 

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

</SCRIPT>

<STYLE type=text/css>

/*타임*/

#count {

 height: 167px;

 color: #000;

 padding-left: 100px;

 padding-top:130px;

 background-image: url(http://www.bb.co.kr/data/201302/IJ13607483252985/12.jpg);

 background-repeat: no-repeat;

}

#bt {

 height: 16px;

 width: 49;

 padding-left: 100px;

 padding-top: 0px;

}

</STYLE>

<TABLE cellSpacing=0 cellPadding=0>

<TBODY>

<TR>

<TD height=167 width=256>

<DIV id=count><SPAN style="FONT: bold 12px Gulim; COLOR: #000" id=counter1></SPAN><FONT style="FONT-FAMILY: '굴림'; size: 7px">시간</FONT> <SPAN style="FONT: bold 12px Gulim; COLOR: #000" id=counter2></SPAN><FONT style="FONT-FAMILY: '굴림'; size: 7px">분</FONT> <SPAN style="FONT: bold 12px Gulim; COLOR: #000" id=counter3></SPAN><FONT style="FONT-FAMILY: '굴림'; size: 7px">초 남음</FONT>

<SPAN style="padding-left:30px;"></SPAN></div>

</TD></TR></TBODY></TABLE>

<SCRIPT>getTime()</SCRIPT>

|

댓글 1개

2020-06-05 (금) 17:30:55
좋은정보 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
기타 18-09-28 조회 8,916
jQuery 18-09-21 조회 6,443
기타 18-09-06 조회 3,321
PHP 18-08-29 조회 4,011
JavaScript 18-08-29 조회 6,903
MySQL 18-08-12 조회 3,723
MySQL 18-08-11 조회 3,401
PHP 18-07-31 조회 2,902
PHP 18-07-20 조회 3,299
기타 18-07-12 조회 3,689
PHP 18-07-12 조회 2,904
PHP 18-07-11 조회 4,259
PHP 18-07-06 조회 3,905
JavaScript 18-07-03 조회 3,903
JavaScript 18-06-26 조회 3,591
PHP 18-06-16 조회 6,095
PHP 18-06-05 조회 3,497
OS 18-05-02 조회 3,573
기타 18-05-01 조회 2,961
PHP 18-04-28 조회 3,310
웹서버 18-04-23 조회 2,942
PHP 18-04-14 조회 4,341
기타 18-03-27 조회 3,876
기타 18-03-23 조회 6,295
기타 18-03-16 조회 4,781
JavaScript 18-03-07 조회 5,155
PHP 18-03-02 조회 4,564
JavaScript 18-02-18 조회 4,987
PHP 18-01-30 조회 6,274
jQuery
[jQuery]
18-01-28 조회 3,190