<?php $thour=17 ?>
<script>
 
var dateObj = new Date();
var month = dateObj.getUTCMonth() + 1; //months from 1-12
var day  = dateObj.getUTCDate();
var year = dateObj.getUTCFullYear();
var hour = dateObj.getHours();
var minute = dateObj.getMinutes();
var second = dateObj.getSeconds();

//var end = new Date('13 Apr 2016 13:30:00');
var end  = new Date(year,month-1,day,<?php echo $thour?>,0,0 );

var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour *24;
var timer;

function showRemaining()
{
    var now = new Date();
    var distance = end - now;
    if (distance < 0 ) {
       // handle expiry here..
    clearInterval( timer ); // stop the timer from continuing ..
    location.reload();
  
       //alert('Expired'); // alert a message that the timer has expired..
    }
    var days = Math.floor(distance / _day);
    var hours = Math.floor( (distance % _day ) / _hour );
    var minutes = Math.floor( (distance % _hour) / _minute );
    var seconds = Math.floor( (distance % _minute) / _second );
    var milliseconds = parseInt(distance % _second /10);

/*
    var countdownElement = document.getElementById('timer');
 
 countdownElement.innerHTML = days  + 'd ' +
                                 hours + 'h ' +
                                 minutes + 'm ' +
                                 seconds + 's ' +
                                 milliseconds + 'ms';
*/
 
 if(hours<10){
  hours = "0" + hours;
 }
 if(minutes<10){
  minutes = "0" + minutes;
 }
 if(seconds<10){
  seconds = "0" + seconds;
 }
 
 if(milliseconds<10){
  milliseconds = "0"+milliseconds;
 }

 var thour = document.getElementById('thour');
 var tminute = document.getElementById('tminute');
 var tsecond = document.getElementById('tsecond');
 var tms = document.getElementById('tms');
 
 thour.innerHTML = hours;
 tminute.innerHTML=minutes;
 tsecond.innerHTML=seconds;
 tms.innerHTML=milliseconds;
 
}

timer = setInterval(showRemaining, 10);

</script>


<div id="timer">
 <span id="thour"></span>
 <span class="sp">:</span>
 <span id="tminute"></span>
 <span class="sp">:</span>
 <span id="tsecond"></span>
 <span class="sp">:</span>
 <span id="tms"></span>
</div>

2015/06/15 15:36 2015/06/15 15:36
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/688

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/688

트랙백 주소 :: 이 글에는 트랙백을 보낼 수 없습니다

트랙백 RSS :: http://blog.visualp.com/rss/trackback/688

트랙백 ATOM :: http://blog.visualp.com/atom/trackback/688