JAVASCRIPT 날짜 카운트다운 코드양식

홈 > IT > IT정보
IT정보

JAVASCRIPT 날짜 카운트다운 코드양식

1 confg 0 138 0 0
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

function getTime() {

now = new Date();

// 원하는 날짜, 시간 정확하게 초단위까지 기입.
dday = new Date('07/01/2019 06:00:00 PM');

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("counter0").innerHTML = daysRound;
document.getElementById("counter1").innerHTML = hoursRound;
document.getElementById("counter2").innerHTML = minutesRound;
document.getElementById("counter3").innerHTML = secondsRound;
newtime = window.setTimeout("getTime();", 1000);

if(Math.floor(dday.getTime() / 1000) <= Math.floor(now.getTime() / 1000) + 1) {
    clearTimeout(newtime);
    document.getElementById("counter0").innerHTML = 0;
    document.getElementById("counter1").innerHTML = 0;
    document.getElementById("counter2").innerHTML = 0;
    document.getElementById("counter3").innerHTML = 0;
}

}

</SCRIPT>

<STYLE type=text/css>

/*타임*/
#count {
    height: 30px;
    color: #000;
    padding-left: 10px;
    padding-top:10px;
}
#bt {
    height: 16px;
    width: 49;
    padding-left: 100px;
    padding-top: 0px;
}
</STYLE>


<center>
	<TABLE cellSpacing=0 cellPadding=0>
	<TBODY>
	<TR>
	<TD height="100%" width="100%">
	<DIV id=count>
	<FONT style="FONT-FAMILY: '굴림'; size: 7px">여자친구 FEVER 컴백까지</FONT>
	<SPAN style="FONT: bold 12px Gulim; COLOR: #000" id=counter0></SPAN>
	<FONT style="FONT-FAMILY: '굴림'; size: 7px">일</FONT> 
	<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></center>

	<SCRIPT>getTime()</SCRIPT>

최근글


새댓글


Facebook Twitter GooglePlus KakaoStory KakaoTalk NaverBand
PlusFriend Chat