tux-world
دوشنبه 09 اسفند 1389, 12:10 عصر
این کد چرا زمان رو درست نشون نمیده ؟
<script type="text/javascript">
function g(id){return document.getElementById(id);}
var now = new Date();
var h= now.getHours();
var m= now.getMinutes();
var s= now.getSeconds();
var timeValue='';
function DigitalClock (IsHour,IsMinute,IsSecond){
s++;
if(s>=60){s =-(60-s);m=parseInt(m)+1;}
if(m>=60){m =-(60-m);h=parseInt(h)+1;}
if(h>=24){h =-(24-h);}
if(s<=9){ts="0"+s;}else{ts=s;}
if(m<=9){tm="0"+m;}else{tm=m;}
if(h<=9){th="0"+h;}else{th=h;}
timeValue = (h >= 12) ?" بعدازظهر ":" قبلازظهر ";
this.Hour=th;
this.Minute=tm;
this.Second=ts;
if (IsHour){g("DClock").innerHTML=th;}
if (IsMinute){g("DClock").innerHTML +=":"+tm;}
if (IsSecond){g("DClock").innerHTML +=":"+ts;}
g("DClock").innerHTML +=timeValue;
setTimeout("DigitalClock("+IsHour+","+IsMinute+","+IsSecond+")",1000);
};
</script>
<script type="text/javascript">
function g(id){return document.getElementById(id);}
var now = new Date();
var h= now.getHours();
var m= now.getMinutes();
var s= now.getSeconds();
var timeValue='';
function DigitalClock (IsHour,IsMinute,IsSecond){
s++;
if(s>=60){s =-(60-s);m=parseInt(m)+1;}
if(m>=60){m =-(60-m);h=parseInt(h)+1;}
if(h>=24){h =-(24-h);}
if(s<=9){ts="0"+s;}else{ts=s;}
if(m<=9){tm="0"+m;}else{tm=m;}
if(h<=9){th="0"+h;}else{th=h;}
timeValue = (h >= 12) ?" بعدازظهر ":" قبلازظهر ";
this.Hour=th;
this.Minute=tm;
this.Second=ts;
if (IsHour){g("DClock").innerHTML=th;}
if (IsMinute){g("DClock").innerHTML +=":"+tm;}
if (IsSecond){g("DClock").innerHTML +=":"+ts;}
g("DClock").innerHTML +=timeValue;
setTimeout("DigitalClock("+IsHour+","+IsMinute+","+IsSecond+")",1000);
};
</script>