我正在处理php / javascript,它显示了日期的倒计时。 这个想要显示从服务器时间到那个时间。
<?php date_default_timezone_set( "Europe/Berlin"); ?>
<script>
var end = new Date('04/12/2013 9:0 PM');
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;
function showRemaining() {
var now = <? php echo date('D M d Y H:i:s O') ?> ;
var distance = end - now;
if(distance < 0) {
clearInterval(timer);
document.getElementById('countdown').innerHTML = 'EXPIRED!';
return;
}
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);
document.getElementById('countdown').innerHTML = days + 'd ';
document.getElementById('countdown').innerHTML += hours + ':';
document.getElementById('countdown').innerHTML += minutes + ':';
document.getElementById('countdown').innerHTML += seconds;
}
timer = setInterval(showRemaining, 1000);
</script>
我试过这种方式但没有任何成功..
答案 0 :(得分:1)