mam oto taki kodzik który na podstawie ilości sekund oblicza ile pozostało godzin minut sekund.
<script type="text/javascript"> var end = <?php echo $p_time; ?>; var now = 0; function next_fight() { var s = end - now; temp = s; if(s > 0) { temp %= 86400; hours = Math.floor(temp / 3600); if(hours.length == 1) { hours = "0"+hours; } temp %= 3600; minutes = Math.floor(temp / 60); if(minutes.length == 1) { minutes = "0"+minutes; } temp %= 60; seconds = temp; if(seconds.length == 1) { seconds = "0"+seconds; } var result = hours + ":" + minutes + ":" + seconds +" "+ seconds.length; document.getElementById('next_time').innerHTML = result; now++; setTimeout("next_fight()", 1000); } else { location.href="<? echo $host; ?><? echo $file; ?>"; } } window.onload = next_fight(); </script>
wszystko super ale niepodobało mi się że gdy do chodiły minuty lub sekundy do końca to było 9,8 itd a chciałbym uzyskać 09 itd lecz length cały czas zwaraca mi undefined dlaczego? co zrobiłem źle.
Dobra juz naprawiłem trzeba było zrobić taK : toString().length