기본적으로 나는 자바 스크립트를 잘하고 내 프로젝트에 대한 더 나은 카운트 다운 타이머를 원합니다. 내가 같이하기를 원하는자바 스크립트 PHP 좋은 카운트 다운 타이머
1시 25분 5초
:
1시간 25 분 5 초 순간 내 타이머는 다음과 같이 보입니다
하지만 나는 또한 그것이 영리하기를 바랍니다. 따라서 25 분이면
25 분으로 표시됩니다.
이 내 현재의 자바 스크립트 코드 : 제가 원하는 무엇을 출력 할 수 있도록
function secondCountdown(){
if(typeof(skip) == "undefined"){
skip = "set";
} else {
var timeleft = document.getElementById("timeleft").innerHTML;
var time_split = timeleft.split(":");
if(parseInt(time_split[0]) < 10){
time_split[0] = time_split[0].charAt(1);
}
if(parseInt(time_split[1]) < 10){
time_split[1] = time_split[1].charAt(1);
}
if(parseInt(time_split[2]) < 10){
time_split[2] = time_split[2].charAt(1);
}
seconds = parseInt(time_split[2]) + parseInt(time_split[1]*60) + parseInt(time_split[0]*3600);
seconds -= 1;
if(seconds > 0){
var hours= Math.floor(seconds/3600);
seconds %= 3600;
var minutes = Math.floor(seconds/60);
seconds %= 60;
var timeleft = ((hours < 10) ? "0" : "") + hours + ":" + ((minutes < 10) ? "0" : "") + minutes + ":" + ((seconds < 10) ? "0" : "") + seconds;
document.getElementById("timeleft").innerHTML = timeleft;
} else {
document.getElementById("timeleft").innerHTML = "";
window.location='test.php?pageid=' + getURLParam("pageid");
return false;
}
}
setTimeout("secondCountdown()",1000);
}
window.onload = secondCountdown;
어쩌면 누군가가 편집 할 수 있을까?
편집 :
이것은 타이머의 PHP 측면입니다. 대신이 라인의
<span id="timeleft">
$master = $timer['gta_time'] - time();
echo date("00:i:s", $timer['gta_time'] - time());
</span>
PHP 또는 JavaScript로 이것을 원하십니까? – Brad
글쎄 JS 스크립트에 스크립트를 원하지만 시간은 원래 PHP에서 온다. –