Find out how many days a time interval



  • Good afternoon! There's two input. That's where a man hits two dates. Date of departure and date of departure. How to know how many days between these dates. For example, the date of departure is 16.06.2016. Column 6. I want to do jquery.



  • https://stackoverflow.com/questions/3224834/get-difference-between-2-dates-in-javascript answer your question.

    • Create two variable types of Date, transferring dates necessarily as a row wrapped.
    • Get the difference between the dates in milliseconds.
    • Use a division to lead to days.
    var date1 = new Date("7/13/2010");
    

    var date2 = new Date("12/15/2010");

    var timeDiff = Math.abs(date2.getTime() - date1.getTime());

    var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));

    alert(diffDays);


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2