So, guys, I want to do a countdown timer that tells you the time you came in, and it does the sum for 6hrs and 20mins, and tells you the time you're leaving and picks up that hour and subtracts Current computer time and play pro countdown timer. In my current code I have a clock that pulls the current time of the computer and a countdown timer that tells you the time and it goes back, so my problems are as follows:
1 - My accountant does not support hours, only minutes and seconds.
2 - I do not know how to add the time entered from the set time of 06: 20: 00hrs and then show somewhere on the page this time.
3 - I do not know how to do the subtraction of the time that the person will leave the current time of the computer and play that time pro counter.
<HTML>
<HEAD>
<TITLE>Contagem Regressiva</TITLE>
</HEAD>
<BODY>
<CENTER>
<FORM name="sw">
<TABLE border="0" width="100%">
<tr align="center">
<td>
<table border="3" width="30%">
<tr align="center">
<td>
<SPAN ID="Clock"></SPAN>
<br>
<input type="text" name="beg2" size="7" value="00:05">
</td>
<td>
<input type="button" value="Iniciar" onclick="Down()">
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="text" name="disp2" size="20">
</td>
</tr>
</table>
</td>
</tr>
</TABLE>
</FORM>
</CENTER>
<SCRIPT LANGUAGE="JavaScript">
var Elem = document.getElementById("Clock");
function Horario(){
var Hoje = new Date();
var Horas = Hoje.getHours();
if(Horas < 10){
Horas = "0"+Horas;
}
var Minutos = Hoje.getMinutes();
if(Minutos < 10){
Minutos = "0"+Minutos;
}
var Segundos = Hoje.getSeconds();
if(Segundos < 10){
Segundos = "0"+Segundos;
}
Elem.innerHTML = Horas+":"+Minutos+":"+Segundos;
}
window.setInterval("Horario()",1000);
var down;
var cmin2,csec2;
function Minutes(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(0,i));
}
function Seconds(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(i+1,data.length));
}
function Display(min,sec) {
var disp;
if(min<=9){
disp=" 0";
}else{
disp=" ";
}
disp+=min+":";
if(sec<=9){
disp+="0"+sec;
}else{
disp+=sec;
}
return(disp);
}
function Down() {
cmin2=1*Minutes(document.sw.beg2.value);
csec2=0+Seconds(document.sw.beg2.value);
DownRepeat();
}
function DownRepeat() {
csec2--;
if(csec2==-1) {
csec2=59;
cmin2--;
}
document.sw.disp2.value=Display(cmin2,csec2);
if((cmin2==0)&&(csec2==0)){
alert("Acabou a Contagem!!!");
}else{
down=setTimeout("DownRepeat()",1000);
}
}
</SCRIPT>
</BODY>
</HTML>