Hola como esta todo por alla tiempo sin verte por estos lares
Bueno te cuento si quieres la hora actual desde el lado del cliente usas javascipt y te quedaria de esta firma
este script fue sacado de la pagina de tunait.
Código:
<html>
<head>
<script>
function hora(){
var fecha = new Date()
var hora = fecha.getHours()
var minuto = fecha.getMinutes()
var segundo = fecha.getSeconds()
if (hora < 10) {hora = "0" + hora}
if (minuto < 10) {minuto = "0" + minuto}
if (segundo < 10) {segundo = "0" + segundo}
var horita = hora + ":" + minuto + ":" + segundo
document.getElementById('hora').firstChild.nodeValue = horita
tiempo = setTimeout('hora()',1000)
}
function inicio(){
document.write('<span id="hora">')
document.write ('000000</span>')
hora()
}
</script>
</head>
<body>
<div style="position: absolute; width: 94px; height: 20px; z-index: 1; left: 5px; top: 4px" id="capa19">
<b>Hora Actual:</b></div>
<div style="position: absolute; width: 94px; height: 20px; z-index: 1; left: 213px; top: 4px" id="capa20">
<b>Fecha Actual:</b></div>
<div align="center" style="position: absolute; width: 100px; height: 20px; z-index: 2; left: 102px; top: 4px" id="capa21">
<script> inicio()</script>
</body>
</html>
Ahora bien si lo que necesitas es la hora actual del servidor entonces haces esto:
Código PHP:
// esto lo pones dentro del header.
<?PHP
$a=date("H"); //hora
$b=date("i"); //minuto
$c=date("s"); //segundo
?>
Luego usamos el script de arriba y nos quedaria asi:
Código HTML:
<html>
<head>
<?PHP
$a=date("H"); //hora
$b=date("i"); //minuto
$c=date("s"); //segundo
?>
<script>
function hora(){
//var fecha = new Date()
var hora = <? echo "$a"; ?>
var minuto = <? echo "$b"; ?>
var segundo = <? echo "$c"; ?>
if (hora < 10) {hora = "0" + hora}
if (minuto < 10) {minuto = "0" + minuto}
if (segundo < 10) {segundo = "0" + segundo}
var horita = hora + ":" + minuto + ":" + segundo
document.getElementById('hora').firstChild.nodeValue = horita
tiempo = setTimeout('hora()',1000)
}
function inicio(){
document.write('<span id="hora">')
document.write ('000000</span>')
hora()
}
</script>
</head>
<body>
<div style="position: absolute; width: 94px; height: 20px; z-index: 1; left: 5px; top: 4px" id="capa19">
<b>Hora Actual:</b></div>
<div style="position: absolute; width: 94px; height: 20px; z-index: 1; left: 213px; top: 4px" id="capa20">
<b>Fecha Actual:</b></div>
<div align="center" style="position: absolute; width: 100px; height: 20px; z-index: 2; left: 102px; top: 4px" id="capa21">
<script> inicio()</script>
</body>
</html>
Comentame como te fue.
Suerte y Salu2.
Bye