Foros del Web » Programando para Internet » Javascript »

problema con el weeks

Estas en el tema de problema con el weeks en el foro de Javascript en Foros del Web. aver es que tengo esto para crear un time de tiempo de cuanto lleva el foro activo @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código Javascript : Ver original function ...
  #1 (permalink)  
Antiguo 18/10/2012, 21:13
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 759
Antigüedad: 11 años, 10 meses
Puntos: 10
problema con el weeks

aver es que tengo esto para crear un time de tiempo de cuanto lleva el foro activo

Código Javascript:
Ver original
  1. function calcage(secs, num1, num2) {
  2.   s = ((Math.floor(secs/num1))%num2).toString();
  3.   if (LeadingZero && s.length < 2)
  4.     s = "0" + s;
  5.   return  s;
  6. }
  7.  
  8. function CountBack(secs) {
  9.   if (secs < 0) {
  10.     document.getElementById("cntdwn").innerHTML = FinishMessage;
  11.     return;
  12.   }
  13.   DisplayStr = DisplayFormat.replace(/%%W%%/g, calcage(secs,86400000,7));
  14.   DisplayStr = DisplayStr.replace(/%%D%%/g, calcage(secs,86400,100000));
  15.   DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  16.   DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  17.   DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));
  18.  
  19.   document.getElementById("cntdwn").innerHTML = DisplayStr;
  20.   if (CountActive)
  21.     setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
  22. }
  23.  
  24. function putspan(backcolor, forecolor) {
  25.  document.write("<span id='cntdwn'></span>");
  26. }
  27.  
  28. if (typeof(BackColor)=="undefined")
  29.   BackColor = "white";
  30. if (typeof(ForeColor)=="undefined")
  31.   ForeColor= "#2A8827";
  32. if (typeof(TargetDate)=="undefined")
  33.   TargetDate = "12-31-2020 5:00 AM";
  34. if (typeof(DisplayFormat)=="undefined")
  35.   DisplayFormat = "%%W%%w %%D%%d %%H%%h %%M%%m %%S%%s.";
  36. if (typeof(CountActive)=="undefined")
  37.   CountActive = true;
  38. if (typeof(FinishMessage)=="undefined")
  39.   FinishMessage = "no data";
  40. if (typeof(CountStepper)!="number")
  41.   CountStepper = +1;
  42. if (typeof(LeadingZero)=="undefined")
  43.   LeadingZero = true;
  44.  
  45.  
  46. CountStepper = Math.ceil(CountStepper);
  47. if (CountStepper == 0)
  48.   CountActive = false;
  49. var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 1000;
  50. putspan(BackColor, ForeColor);
  51. var dthen = new Date(TargetDate);
  52. var dnow = new Date();
  53. if(CountStepper>0)
  54.   ddiff = new Date(dnow-dthen);
  55. else
  56.   ddiff = new Date(dthen-dnow);
  57. gsecs = Math.floor(ddiff.valueOf()/1000);
  58. CountBack(gsecs);

codigo que muestra el tiempo

Código PHP:
Ver original
  1. <html>
  2. <head>
  3. </head>
  4.  
  5. <body>
  6. <?php
  7. $date = new DateTime('2012-10-17 03:14:15');
  8. $start = $date->format('Y/m/d h:i:s');
  9. ?>
  10. <br>
  11. Fecha:<script type="text/javascript" language="JavaScript">
  12.     TargetDate = "<?php echo $start; ?>";
  13.     CountActive = true;
  14. </script>
  15. <script type="text/javascript"  language="JavaScript" src="js/time.js"></script>
  16. </body>
  17. </html>

Última edición por xoceunder; 18/10/2012 a las 21:19
  #2 (permalink)  
Antiguo 19/10/2012, 12:26
Avatar de marlanga  
Fecha de Ingreso: enero-2011
Ubicación: Murcia
Mensajes: 1.024
Antigüedad: 13 años, 3 meses
Puntos: 206
Respuesta: problema con el weeks

Usa jsfiddle.net para poner un ejemplo funcionando, así es mas fácil ayudar.
JSFiddle no ejecuta php, asi que sustituyelo por lo que el PHP generaría.

Etiquetas: html, js, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:47.