Y cuando mando los datos directos no funciona por q sera, no lo se ya que he intentado modificarla pero no lo puedo solucionar ayudenme necesito solucionar este problema
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
donde tengo el error:
Código Javascript:
Ver original
<script language="javascript" type="text/javascript"> function Validar(Cadena){ var fe=Cadena; var Dia = parseInt(fe.substr(0,2)); var Mes = parseInt(fe.substr(3,4)); var Ano = parseInt(fe.substr(6,4)); var mensaje=""; if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900) mensaje= "Año inválido"; if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12) mensaje = "Mes incorrecto"; if (isNaN(Dia) || parseInt(Dia, 10)<1 || parseInt(Dia, 10)>31)mensaje = "Día inválido"; if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) { if (Mes==2 && Dia > 28 || Dia>30) { mensaje= "dia invalido"; } } if (mensaje!="") { alert("Atencion, la fecha es incorrecta"); return false; } else { return true; } } function validahora(str) { var mensaj=str; var des=""; var reshor2= mensaj.split(':'); var hora4= reshor2[0]; var minuto4 = reshor2[1]; var segundo4 = reshor2[2]; if(hora4 > 24) des="error"; if(minuto4 > 60) des="error"; if(segundo4 > 60) des="error"; if (des!="") { alert("Error en la hora: \n\n introduce la fecha en este tipo HH:MM:SS "); return false; } else { return true; } } function increaseTime(datehor,time) { var inc = time; var de = datehor; var cot = de.split(' '); var fe = toc[0]; var hor = toc[1]; var incSecond= 0; var incMinute= 0; var incHour= 0; var incDay= 0; var incMonth= 0; var incYear= 0; while (inc >0) { if (inc < 86400) { if (inc < 3600) { if (inc < 60) { //Segundos incSecond=inc; inc=inc-incSecond; } else { //Minutos incMinute=Math.floor(inc/60); inc=inc-(incMinute*60); } } else { //Horas incHour=Math.floor(inc/3600); inc=inc-(incHour*3600); } } else { //Dias incDay=Math.floor(inc/86400); inc=inc-(incDay*86400); } //return resta(incDay,incHour,incMinute); } //descomponer las fechas en dia mes y año //var fe=document.getElementById("fecha").value; var esvalido=Validar(fe); if (esvalido==false) { return; } var day = parseInt(fe.substr(0,2)); var month = parseInt(fe.substr(3,4)); var year = parseInt(fe.substr(6,4)); //comprobar las restas de las los dias meses y años if(incDay > 0 ){ day=day-1; } if(day < 1 ){ month=month-1; } if (month <1){ year=year-1; } if (month==0){ month=12; } //asignando las variables de los dias del año var ene=31; var feb=28; var feb2=29; var mar=31; var abr=30; var may=31; var jun=30; var jul=31; var ago=31; var sep=30; var oct=31; var nov=30; var dic=31; // checa si el año es bisiesto var tipo = ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) ? true : false; if(day<1){ if(tipo==true){if(month==1){ day=ene; }else{ if(month==2){ day=feb2; }else{ if(month==3){ day=mar; }else{ if(month==4){ day=abr; }else{ if(month==5){ day=may; }else{ if(month==6){ day=jun; }else{ if(month==7){ day=jul; }else{ if(month==8){ day=ago; }else{ if(month==9){ day=sep; }else{ if(month==10){ day=oct; }else{ if(month==11){ day=nov; }else{ if(month==12){ day=31; } } } } } } } } } } } } }else{ if(month==1){ day=ene; } else{ if(month==2){ day=feb; }else{ if(month==3){ day=mar; }else{ if(month==4){ day=abr; }else{ if(month==5){ day=may; }else{ if(month==6){ day=jun; } else{ if(month==7){ day=jul; }else{ if(month==8){ day=ago; }else{ if(month==9){ day=sep; }else{ if(month==10){ day=oct; }else{ if(month==11){ day=nov; }else{ if(month==12){ day=31; } } } } } } } } } } } } } } //var hor=document.getElementById("hora").value; var esvalido2=validahora(hor); if (esvalido2==false) { return; } var reshor= hor.split(':'); var hora = reshor[0]; var minuto = reshor[1]; var segundo = reshor[2]; var unhora = 24; var unmin = 60; var unseg = 60; if( hora== 0){ unhora = 23; }else{ unhora= 24; } var tothoras= hora - incHour; var totminutos= minuto - incMinute; var totsegundos= segundo - incSecond; if(totsegundos < 0){ var tot= unseg - (incSecond-segundo); totminutos=totminutos-1; totsegundos = tot; } if(totminutos < 0){ var tot2 = unmin - (incMinute - minuto); tothoras= tothoras - 1; totminutos= tot2; } if(tothoras < 0){ var tot3 = unhora -(incHour - hora); day = day-1; tothoras = tot3; } if(incDay > 0 ){ day=day-1; } if(day < 1 ){ month=month-1; } if (month <1){ year=year-1; } if (month==0){ month=12; } //asignando las variables de los dias del año var ene=31; var feb=28; var feb2=29; var mar=31; var abr=30; var may=31; var jun=30; var jul=31; var ago=31; var sep=30; var oct=31; var nov=30; var dic=31; // checa si el año es bisiesto var tipo = ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) ? true : false; if(day<1){ if(tipo==true){if(month==1){ day=ene; }else{ if(month==2){ day=feb2; }else{ if(month==3){ day=mar; }else{ if(month==4){ day=abr; }else{ if(month==5){ day=may; }else{ if(month==6){ day=jun; }else{ if(month==7){ day=jul; }else{ if(month==8){ day=ago; }else{ if(month==9){ day=sep; }else{ if(month==10){ day=oct; }else{ if(month==11){ day=nov; }else{ if(month==12){ day=31; } } } } } } } } } } } } }else{ if(month==1){ day=ene; }else{ if(month==2){ day=feb; }else{ if(month==3){ day=mar; }else{ if(month==4){ day=abr; }else{ if(month==5){ day=may; }else{ if(month==6){ day=jun; }else{ if(month==7){ day=jul; }else{ if(month==8){ day=ago; }else{ if(month==9){ day=sep; }else{ if(month==10){ day=oct; }else{ if(month==11){ day=nov; }else{ if(month==12){ day=31; } } } } } } } } } } } } } } alert ("Resultado de la operacion: \n\n La fecha inicial es " + fe + " con hora: " + hor + "\n\n Con una resta de: " + time + " segundos. \n\n que con la conversion queda: " + incDay + " dia " + incHour + ":" + incMinute + ":" + incSecond + " horas \n\n y como resultado da: \n " + day + "/" + month + "/" + year + " con " + tothoras + ":" + totminutos + ":" + totsegundos ); } </script> <body> <?php $datehor='25/01/2011 19:52:16'; $tiempo=69310; ?> <a href="javascript:increaseTime(<?php echo $fe; ?>,<?php echo $fe; ?>,<?php echo $tiempo; ?>)">mandar datos</a>