Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/06/2012, 07:22
santi2892009
 
Fecha de Ingreso: mayo-2012
Mensajes: 363
Antigüedad: 11 años, 10 meses
Puntos: 0
contador regresivo con hora del servidor

olaa encontre este x internet pero falla algo nose el que y si alguien me dirira como añadir la hora del servidor??:


<!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>Documento sin título</title>
</head>

<body>
<!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>Tiempo que resta</title>
</head>
<script type="text/javascript">
var month = 5; //mes del evento 0:enero, 1:febrero, ...
var day = 11; //dia del evento
var year = 2010; //año del evento
var one_day = 1000*60*60*24; //tiempo en milisegundos de duracion de un dia
var one_hour= 1000*60*60; //tiempo en milisegundos de duracion de una hora
var one_min = 1000*60; //tiempo en milisegundos de duracion de un minuto
var one_seg = 1000; //tiempo de duracion de 1 segundo
var aux; //variable que me permite almacenar datos temporales
var evento = new Date(year,month,day); //dia del evento
var begin = true; //variable para verificar si ya inicio el evento

function count_regressive() {

var today = new Date(<?php time() ?>; //colocamos la hora del servidor

if(today.getMonth()==month && today.getDay()>day) //verificamos si el evento todavia no ocurre
begin = true;

aux = (evento.getTime()-today.getTime()); //obtenemos los milisegundos

var days = Math.ceil(aux/one_day); //dias que faltan

aux = (aux%one_day); //residuo

var hours = Math.ceil(aux/one_hour); //horas que faltan

aux = aux%one_hour; //residuo

var mins = Math.ceil(aux/one_min); //minutos que faltan

aux = aux%one_min; //residuo

var segs = Math.ceil(aux/one_seg); //segundos



document.getElementById('show').innerHTML = days + ' Dias ' + hours + ' horas ' + mins + ' Minutos ' + segs + ' Segundos ' ;

setTimeout("count_regressive()",1000); //para mostrar el contador regresivo
}

</script>
<body onload="count_regressive()">
<h1 id="show">
</h1>
</body>
</html>
</body>
</html>