Como puedo obtener la hora del servidor de forma dinamica, tal como lo hace en javascript pero del servidor aca tengo algo de codigo:
Código Javascript
:
Ver original<html>
<head>
<title>Reloj con Javascript</title>
<script language="JavaScript">
function mueveReloj(){
momentoActual = new Date()
hora = momentoActual.getHours()
minuto = momentoActual.getMinutes()
segundo = momentoActual.getSeconds()
horaImprimible = hora + " : " + minuto + " : " + segundo
document.form_reloj.reloj.value = horaImprimible
setTimeout("mueveReloj()",1000)
}
</script>
</head>
<body onload="mueveReloj()">
Vemos aquí el reloj funcionando...
<form name="form_reloj">
<input type="text" name="reloj" size="10">
</form>
</body>
</html>
Código HTML:
Ver original<!DOCTYPE html>
function HoraAjax()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ObtenerHora.php",true);
xmlhttp.send();
}
<button type="button" onclick="HoraAjax()">Contenido
</button>
ObtenerHora