I have created a custom Jquery Timer. but i am facing little problem i dont know that is not working for me. below is my code.
function show(Hos, mins, secds) {
var hours = Hos;
var minutes = mins;
var seconds = secds;
var dn = "AM";
if (hours > 12) {
dn = "PM"
hours = hours - 12
}
if (hours == 0)
hours = 12
document.getElementById('<%= Label1.ClientID %>').innerHTML = hours + ":" + minutes + ":" + seconds + " " + dn
if (parseInt(seconds) == 59) {
seconds = 0;
if (parseInt(minutes) == 59) {
if (parseInt(hours) == 12) {
hours = 0;
} else {
hours = parseInt(hours) + 1;
}
} else {
minutes = parseInt(minutes) + 1;
}
} else {
seconds = parseInt(seconds) + 1;
}
setTimeout("show('" + hours + "','" + minutes + "','" + seconds + "'" + " )", 1000)
}
This code is working fine i am passing the hours,mins,seconds first time from the code behind using c#.Now my problem is i want to add “0” if the seconds is less than 9 and minutes less than 9 and hours less than 9. i have tried the following trick but i dont know why its not working for me..
if (seconds <= 9) {
seconds = '0' + parseInt(seconds);
}
Please help me..Actually what happens when i tried this . its concatenate 0 with seconds upto 9 but as 9 comes it restarts from 1. That is the problem.
i have resolve this problem using some trick that is as follow: