我有一个 unix 时间,例如: var later= 135000;
当我稍后取变量时 -= 1000 我能够得到 134000。
但是当我稍后取变量 += 1000 时,我得到 1350001000。
我怎样才能增加我的unix时间?
<script type="text/javascript">
var later = "<?php echo $unix_time; ?>";
var stop= setInterval('countdown()',1000);
function countdown(plus_ten) {
var now = new Date();
var now_time= now.getTime()/1000;
now_time= Math.floor(now_time);
if(plus_ten){
later = later + 1000;
alert(later);
}
var sec = later- now_time;
if(sec<=0){
clearInterval(stop);
alert('hello');
}
sec= Math.floor(sec);
var min = Math.floor(sec / 60);
var hour = Math.floor(min / 60);
hour %= 24;
min %= 60;
sec %= 60;
document.getElementById("hoursBox").innerHTML = hour;
document.getElementById("minsBox").innerHTML = min;
document.getElementById("secsBox").innerHTML = sec;
}
</script>