Foros del Web » Programando para Internet » Javascript »

la hora...

Estas en el tema de la hora... en el foro de Javascript en Foros del Web. Hola a todos,,, toy peleandome con una web y queria ponerle la hora,,¿como puedo ponerle la hora en html?.. Saludos...
  #1 (permalink)  
Antiguo 30/11/2007, 12:54
 
Fecha de Ingreso: noviembre-2005
Mensajes: 111
Antigüedad: 18 años, 5 meses
Puntos: 0
la hora...

Hola a todos,,, toy peleandome con una web y queria ponerle la hora,,¿como puedo ponerle la hora en html?..

Saludos
  #2 (permalink)  
Antiguo 30/11/2007, 12:58
Avatar de DragonX
Colaborador
 
Fecha de Ingreso: mayo-2002
Ubicación: Funkyland
Mensajes: 8.433
Antigüedad: 22 años
Puntos: 177
Re: la hora...

Debés ubicar este script en cualquier parte de la página (dentro de las etiquetas BODY) donde quieras que aparezca la fecha y la hora:

Código HTML:
<script LANGUAGE="JavaScript">
<!-- COMIENZO
Stamp = new Date();
year = Stamp.getYear();
if (year < 2000) year = 1900 + year;
document.write('<font size="2" face="Arial"><B>Fecha: ' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+ year + '</B></font><BR>');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}
document.write('<font size="2" face="Arial"><B>Hora: ' + Hours + ":" + Mins + Time + '</B></font>');
// FIN -->
</script> 
__________________
Desarrollos dosLotos
Calendario Maya, Meditación, Osho
  #3 (permalink)  
Antiguo 01/12/2007, 14:08
 
Fecha de Ingreso: noviembre-2005
Mensajes: 111
Antigüedad: 18 años, 5 meses
Puntos: 0
Sonrisa Re: la hora...

Cita:
Iniciado por DragonX Ver Mensaje
Debés ubicar este script en cualquier parte de la página (dentro de las etiquetas BODY) donde quieras que aparezca la fecha y la hora:

Código HTML:
<script LANGUAGE="JavaScript">
<!-- COMIENZO
Stamp = new Date();
year = Stamp.getYear();
if (year < 2000) year = 1900 + year;
document.write('<font size="2" face="Arial"><B>Fecha: ' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+ year + '</B></font><BR>');
var Hours;
var Mins;
var Time;
Hours = Stamp.getHours();
if (Hours >= 12) {
Time = " P.M.";
}
else {
Time = " A.M.";
}
if (Hours > 12) {
Hours -= 12;
}
if (Hours == 0) {
Hours = 12;
}
Mins = Stamp.getMinutes();
if (Mins < 10) {
Mins = "0" + Mins;
}
document.write('<font size="2" face="Arial"><B>Hora: ' + Hours + ":" + Mins + Time + '</B></font>');
// FIN -->
</script> 


No me funciona,, tengo puesto esto e iria aqui......

<div align="center">
<center>
<table border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="740" cellpadding="0" id="AutoNumber4" height="5">
<tr>
<span style="font-size: 8pt"><script languaje="JavaScript">

var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Juev es","Viernes","Sabado")
var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Ju nio","Julio","Agosto","Septiembre","Octubre","Novi embre","Diciembre")
document.write("<font-size: 8pt><font color='#f90001' face='Arial'>"+dayarray[day]+" "+daym+" de "+montharray[month]+" de "+year+"</font></small>")
</script></span>
<td><span style="font-size: 1pt">&nbsp;
<img border="0" src="imagenes/barra41.jpg" width="734" height="28"></span></td>
</script>



tu me diras si va bien,,,, esto q tenia puesto era solo de la fecha.

chao
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 08:37.