Reloj que tome hora servidor
Publicado por Lucas (4 intervenciones) el 07/02/2007 20:32:19
Hola tengo un proyecto y por ahi me encontre un codigo lo utilice y todo bien, solo que me acabo de dar cuenta que la hora que me toma es la del cliente, ocupo que me tome la hora de mi servidor, como puedo hacerle???, gracias de antemano.
Codigo:
<html>
<head>
<title>Reloj con Javascript</title>
<script language="JavaScript">
function mueveReloj(){
momentoActual = new Date()
hora = momentoActual.getHours()
minuto = momentoActual.getMinutes()
segundo = momentoActual.getSeconds()
str_segundo = new String (segundo)
if (str_segundo.length == 1)
segundo = "0" + segundo
str_minuto = new String (minuto)
if (str_minuto.length == 1)
minuto = "0" + minuto
str_hora = new String (hora)
if (str_hora.length == 1)
hora = "0" + hora
horaImprimible = hora + " : " + minuto + " : " + segundo
document.form_reloj.reloj.value = horaImprimible
setTimeout("mueveReloj()",1000)
}
</script>
</head>
<body onload="mueveReloj()">
<form name="form_reloj">
<input type="text" name="reloj" size="10" style="background-color : Black; color : White; font-family : Verdana, Arial, Helvetica; font-size : 18pt; text-align : center;" onfocus="window.document.form_reloj.reloj.blur()">
</form>
</body>
</html>
Codigo:
<html>
<head>
<title>Reloj con Javascript</title>
<script language="JavaScript">
function mueveReloj(){
momentoActual = new Date()
hora = momentoActual.getHours()
minuto = momentoActual.getMinutes()
segundo = momentoActual.getSeconds()
str_segundo = new String (segundo)
if (str_segundo.length == 1)
segundo = "0" + segundo
str_minuto = new String (minuto)
if (str_minuto.length == 1)
minuto = "0" + minuto
str_hora = new String (hora)
if (str_hora.length == 1)
hora = "0" + hora
horaImprimible = hora + " : " + minuto + " : " + segundo
document.form_reloj.reloj.value = horaImprimible
setTimeout("mueveReloj()",1000)
}
</script>
</head>
<body onload="mueveReloj()">
<form name="form_reloj">
<input type="text" name="reloj" size="10" style="background-color : Black; color : White; font-family : Verdana, Arial, Helvetica; font-size : 18pt; text-align : center;" onfocus="window.document.form_reloj.reloj.blur()">
</form>
</body>
</html>
Valora esta pregunta


0