PDA

View Full Version : عدم نمایش صحیح زمان



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) ?"&nbsp;&nbsp;بعد‌از‌ظهر&nbsp;&nbsp;":"&nbsp;&nbsp;قبل‌از‌ظهر&nbsp;&nbsp;";
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>

hossin.esm
دوشنبه 09 اسفند 1389, 18:31 عصر
سلام
چه مشکلی داره.




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<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) ?"&nbsp;&nbsp;بعد‌از‌ظهر&nbsp;&nbsp;": "&nbsp;&nbsp;قبل‌از‌ظهر&nbsp;&nbsp ;";
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>
</head>
<body onLoad="DigitalClock (h,m,s)">
<p id='DClock'></p>
</body>
</html>