시간 카운트

Language/JAVASCRIPT 2010. 6. 23. 11:41


<HTML>
<HEAD>
    <TITLE>BLUE-B</TITLE>
<SCRIPT type="text/javascript">
<!--
function reverse_counter(){
    today = new Date();
    d_day = new Date("Jun 22 2010 20:51:00");
    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;

    //텍스트 출력 부분

    document.all["counter1"].innerHTML = "경매종료시간 :"+ daysRound +     dy + hoursRound + hr + minutesRound + min + secondsRound + sec;

    newtime = window.setTimeout("reverse_counter();", 1000);
}
//-->
</script>
</HEAD>
<BODY onLoad="reverse_counter()">


<B><div id="counter1" style="font-size:15pt;"></div></B>

<form name="counter">
<input type="text" name="counter_box" size="40" >
</form>

</body>
</html>

출처 - http://www.blueb.co.kr/

====================================================================================================

<SCRIPT LANGUAGE="JavaScript">
 
 function reverse_counterz(){ 
  today = new Date();
  d_day = new Date("december 05 2010 23:59:59");
  
  days = (d_day - today) / 1000 / 60 / 60 / 24;
  daysRound = Math.floor(days);   

  hours1 = (d_day - today) / 1000 / 60 / 60 - (24 * daysRound);     // 일을 미포함한 시간 예) 1 일 12시간
  hoursRound = Math.floor(hours1); 

  hours2 = (d_day - today) / 1000 / 60 / 60 - (24 * daysRound)+(daysRound*24); // 일을 포함한 시간 예) 36시간
  hoursRound2 = Math.floor(hours2);

  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);  
  
  if(hoursRound2<0){
   window.clearTimeout(newtime);
  }else{
   document.getElementById('hh').innerHTML = hoursRound2;
   document.getElementById('mm').innerHTML = minutesRound;
   document.getElementById('ss').innerHTML = secondsRound;
   newtime = window.setTimeout("reverse_counterz();", 1000);  
  }
  
 }
reverse_counterz();
//-->
</SCRIPT>

'Language > JAVASCRIPT' 카테고리의 다른 글

랜덤 정수 출력  (0) 2010.07.13
종결되지 않은 문자열 상수입니다  (0) 2010.07.05
새창 열기  (0) 2010.06.11
형변환  (0) 2010.06.11
시작페이지, 즐겨찾기 추가  (0) 2010.06.08
: