Foros del Web » Programando para Internet » Javascript »

pasar dias a meses

Estas en el tema de pasar dias a meses en el foro de Javascript en Foros del Web. Hola. Intentando la siguiente función para convertir fechas no puedo pasar el resultado de días a meses. Se os ocurre algo? @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código Javascript ...
  #1 (permalink)  
Antiguo 28/06/2012, 12:00
 
Fecha de Ingreso: junio-2008
Mensajes: 291
Antigüedad: 15 años, 10 meses
Puntos: 9
pasar dias a meses

Hola. Intentando la siguiente función para convertir fechas no puedo pasar el resultado de días a meses. Se os ocurre algo?

Código Javascript:
Ver original
  1. function recalcDateDiff()
  2. {
  3.  var myForm = document.form1;
  4.  var firstDay = myForm.firstDay.options[myForm.firstDay.selectedIndex].value;
  5.  var secondDay =
  6.      myForm.secondDay.options[myForm.secondDay.selectedIndex].value;
  7.  var firstMonth =
  8.      myForm.firstMonth.options[myForm.firstMonth.selectedIndex].value;
  9.  var secondMonth =
  10.      myForm.secondMonth.options[myForm.secondMonth.selectedIndex].value;
  11.  var firstYear =
  12.      myForm.firstYear.options[myForm.firstYear.selectedIndex].value;
  13.  var secondYear =
  14.      myForm.secondYear.options[myForm.secondYear.selectedIndex].value;
  15.  var firstDate = new Date(firstDay + " " + firstMonth + " " + firstYear);
  16.  var secondDate = new Date(secondDay + " " + secondMonth + " " + secondYear);
  17. var daysDiff = (secondDate.valueOf() - firstDate.valueOf());
  18.  daysDiff = Math.floor(Math.abs((((daysDiff  / 1000) / 60) / 60) / 24));
  19.  
  20.  myForm.txtDays.value = daysDiff;
  21.  return true;
  22. }

Etiquetas: dias, meses
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 04:09.