i have 2 calender
i want to calculate
the difference
in no.of days
my question: date
must be in this format dd/mm/yyyy
(date-month-year)
here is my code snippet
$( "#datepicker1" ).datepicker();
$( "#datepicker2" ).datepicker();
$("#datepicker2").change(function(){
var date1 = $( "#datepicker1" ).val();
console.log(date1);
console.log("date 2: "+ $(this).val());
var date2 = $(this).val();
//difference calculation
days = (date2- date1) / (1000 * 60 * 60 * 24);
console.log("difference: "+ days);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/mint-choc/jquery-ui.css">
<div class="demo">
<p>Check in Date: <input id="datepicker1" type="text"></p>
</div><!-- End demo -->
<div class="demo">
<p>Check Out Date: <input id="datepicker2" type="text"></p>
</div><!-- End demo -->