Jquery calculate months between 2 dates -


what achive if user puts in date 08/08/2016 08/09/2016 = 1 month 08/08/2016 01/09/2016 = 1 month 08/08/2016 30/08/2016 = 1 month

so basicly if wants rent room 01/08/2016 30/08/2016 counts 1 month

could me achive jquery?

or point me start.

please have @ code.

please note while testing this; put date in "mm/dd/yyyy" format i.e. date format. hope you

$(document).ready(function() {    $("#calc").click(function() {      var = $("#from").val();      var = $("#to").val();      var monthdifference = 0;      if (from != "" && != "") {        var fromdate = new date(from);        var todate = new date(to);        calculatemonths(fromdate, todate, monthdifference);      }    });      function calculatemonths(fromdate, todate, monthdifference) {        if (fromdate < todate) {        monthdifference++;        fromdate.setmonth(fromdate.getmonth() + 1);        calculatemonths(fromdate, todate, monthdifference);      } else        alert("monthdifference "+monthdifference);    }  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>  from:  <input type="text" id="from" value="08/08/2016"/>to:  <input type="text" id="to" value="10/08/2016"/>    <br/>  <br/>  <button id="calc">calculate</button>


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -