alguien tiene el codigo en javascript de fecha y hora juntos en español
y del tipo:
jueves 12 de enero hora 16:00:30
desde ya gracias
| |||
| script de fecha y hora juntos alguien tiene el codigo en javascript de fecha y hora juntos en español y del tipo: jueves 12 de enero hora 16:00:30 desde ya gracias
__________________ DJJJ |
| ||||
| Con esto podés arrancar:
Código:
<script language="JavaScript" type="text/JavaScript" class="fecha">
var LaFecha=new Date();
var Mes=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
var diasem=new Array('domingo','lunes','martes','miercoles','jueves','viernes','sabado');
var diasemana=LaFecha.getDay();
var FechaCompleta="";
var NumeroDeMes="";
var hora = LaFecha.getHours()
var minuto = LaFecha.getMinutes()
var segundo = LaFecha.getSeconds()
NumeroDeMes=LaFecha.getMonth();
FechaCompleta=diasem[diasemana]+" "+LaFecha.getDate()+" de "+Mes[NumeroDeMes]+" de "+LaFecha.getFullYear()+" "+hora+":"+minuto+":"+segundo;
document.write (FechaCompleta);
</script>
__________________ Fast, lightweight, cross-platform framework for building incredible, powerful JavaScript applications Última edición por Panino5001; 12/01/2006 a las 00:30 |
| |||
| Y Que se actualize automaticamente la hora? Esta Espectacular muy pero muy bueno, y ahora como hacer para que se actualize automaticamente segundo a segundo????? Muchas Graciasssss
__________________ DJJJ |
| ||||
| Fijate en este artículO: http://www.desarrolloweb.com/articulos/2126.php
__________________ Fast, lightweight, cross-platform framework for building incredible, powerful JavaScript applications |
| |||
| que esta mal??? Código HTML: <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Pagina nueva 1</title> <script language="JavaScript" type="text/JavaScript" class="fecha"> function mueveReloj(){ var LaFecha=new Date(); var Mes=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"); var diasem=new Array('domingo','lunes','martes','miercoles','jueves','viernes','sabado'); var diasemana=LaFecha.getDay(); var FechaCompleta=""; var NumeroDeMes=""; var hora = LaFecha.getHours() var minuto = LaFecha.getMinutes() var segundo = LaFecha.getSeconds() NumeroDeMes=LaFecha.getMonth(); FechaCompleta=diasem[diasemana]+" "+LaFecha.getDate()+" de "+Mes[NumeroDeMes]+" de "+LaFecha.getFullYear()+" "+hora+":"+minuto+":"+segundo; document.write (FechaCompleta); setTimeout("mueveReloj()",1000) } </script> </head> <body onload="mueveReloj()">
__________________ DJJJ |
| ||||
| Reemplazalo por esto y te va a funcionar:
Código:
Podés verlo en :http://www.disegnocentell.com.ar/fechajs2.php <html>
<head>
<title>Pagina nueva 1</title>
<script>
function mueveReloj(){
var LaFecha=new Date();
var Mes=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
var diasem=new Array('domingo','lunes','martes','miercoles','jueves','viernes','sabado');
var diasemana=LaFecha.getDay();
var FechaCompleta="";
var NumeroDeMes="";
var hora = LaFecha.getHours();
var minuto = LaFecha.getMinutes();
var segundo = LaFecha.getSeconds();
NumeroDeMes=LaFecha.getMonth();
FechaCompleta=diasem[diasemana]+" "+LaFecha.getDate()+" de "+Mes[NumeroDeMes]+" de "+LaFecha.getFullYear()+" "+hora+":"+minuto+":"+segundo;
document.getElementById('pepe').innerHTML=FechaCompleta;
setTimeout('mueveReloj()',1000)
}
</script>
<body onload="mueveReloj()">
<div id="pepe"></div>
</body>
</html>
__________________ Fast, lightweight, cross-platform framework for building incredible, powerful JavaScript applications |
| |||
| Joder esta de pm, muchas gracias a los 2. Yo lo estaba buscando también. Una última cosa (si no es mucho pedir ) ¿como se le puede dara el formato a los segundos y minutos para cuando ponga 1,2,3,4,5,6,7,8,9 ponga 01,02,03,04,05,06,07,08,09? Muchas gracias de nuevo! |
| ||||
| Con el cero adelante: Sería así: Código PHP:
__________________ Fast, lightweight, cross-platform framework for building incredible, powerful JavaScript applications |
| |||
| Cita:
Iniciado por Panino5001 Sería así: Código PHP: Muchas gracias tio! |
| ||||
| Hola: Hay una forma que a mi gusto es más bonita de mostrar las Fechas completas, y en general cualquier objeto, y es re-definiendo su método toString()... Ejemplo: http://www.forosdelweb.com/f13/fecha-hora-343513/ Pra re-definirlo se usan prototypos y se define así: Date.prototype.toString = function() { //cuerpo de la función... return "objeto"; } Con esa definición al escribir un objeto Date() se muestra la cadena "objeto", pero esa cadena se puede cambiar por lo que deseemos, así que nos serviría:
Código:
Con esto podemos hacer una función más sencilla para mostrar la hora:Date.prototype.toString = function() {
function x(dato) {
return (dato < 10) ? "0" + dato : dato;
}
Meses = ["enero","febrero","marzo","abril","mayo","junio",
"julio","agosto","septiembre","octubre","noviembre","diciembre"];
Días = ["Domingo ", "Lunes ", "Martes ", "Miércoles ", "Jueves ", "Viernes ", "Sábado "];
return Días[this.getDay()] + this.getDate() + " de " + Meses[this.getMonth()] + " de " + this.getFullYear() + ". Hora " + x(this.getHours()) + ":" + x(this.getMinutes()) + ":" + x(this.getSeconds());
}
function muestraFecha() { document.getElementById('pepe').innerHTML = new Date() } y por último actualizarla cada segundo: <body onload="setInterval('muestraFecha()', 1000)" > Por cierto, en estos casos creo que es mejor usar setInterval... Saludos
__________________ Por favor: No hagan preguntas de temas de foros en mensajes privados... no las respondo |
| ||||
| Gracias, Caricatos. No conocía esa función. Muy buena!!!
__________________ Fast, lightweight, cross-platform framework for building incredible, powerful JavaScript applications |