Posted By

sendoa on 10/19/09


Tagged

fechas


Versions (?)

Número de días entre dos fechas (JS)


 / Published in: JavaScript
 

URL: http://blog.oridoki.com/2009/10/08/javascript-diferencia-entre-dos-fechas/

  1. function getNumeroDeNits(){
  2. var d1 = $('#datepicker1').val().split("-");
  3. var dat1 = new Date(d1[2], parseFloat(d1[1])-1, parseFloat(d1[0]));
  4. var d2 = $('#datepicker2').val().split("-");
  5. var dat2 = new Date(d2[2], parseFloat(d2[1])-1, parseFloat(d2[0]));
  6.  
  7. var fin = dat2.getTime() - dat1.getTime();
  8. var dias = Math.floor(fin / (1000 * 60 * 60 * 24))
  9.  
  10. return dias;
  11. }

Report this snippet  

You need to login to post a comment.