Foros del Web » Programando para Internet » Javascript »

capturar la fecha

Estas en el tema de capturar la fecha en el foro de Javascript en Foros del Web. como capturo en un text box la fecha y en otra la hora??? gracias...
  #1 (permalink)  
Antiguo 24/05/2002, 01:49
 
Fecha de Ingreso: diciembre-2001
Ubicación: Peru
Mensajes: 376
Antigüedad: 22 años, 4 meses
Puntos: 0
capturar la fecha

como capturo en un text box la fecha y en otra la hora??? gracias
  #2 (permalink)  
Antiguo 24/05/2002, 02:13
Avatar de Mickel  
Fecha de Ingreso: mayo-2002
Ubicación: Lima, Peru
Mensajes: 4.619
Antigüedad: 22 años
Puntos: 7
Re: capturar la fecha

Código:
<script language='JavaScript'>
function FXOnLoad() {
  var months=new Array(13);
  months[1]="Enero";
  months[2]="Febrero";
  months[3]="Marzo";
  months[4]="Abril";
  months[5]="Mayo";
  months[6]="Junio";
  months[7]="Julio";
  months[8]="Agosto";
  months[9]="Septiembre";
  months[10]="Octubre";
  months[11]="Noviembre";
  months[12]="Diciembre";
  var time=new Date();
  var lmonth=months[time.getMonth() + 1];
  var date=time.getDate();
  var year=time.getYear();
  if (year < 2000) year = year + 1900;
  var hours = timew.getHours();
  var minutes = time.getMinutes();
  var seconds = time.getSeconds()
  var timeValue = "" + ((hours >12) ? hours -12 :hours)
  if (timeValue == "0") timeValue = 12;
  timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  timeValue += (hours >= 12) ? " P.M." : " A.M."
  document.miform.txtfecha.value=date + " de " + lmonth + ", " + year;
  document.miform.txthora.value = timeValue;
}
</script>
...
<body... onLoad='FXOnLoad();'>
...
<form name='miform'...>
<input type='text' name='txtfecha'...>
<input type='text' name='txthora'...>
....
</form>
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:50.