Hi guys,
I try to calculate number of month between 2 selected dates and i just got this code. The problem is this code calculate number of days and i try change the code from
var days = (end - start) / (1000 * 60 * 60 *24) ;
to
var days = (end - start) / (60 * 60 * 24 * 30);
Here the full code :
javascript:
$("#TextBox1").datepicker({
minDate: 0,
maxDate: '+1Y+6M',
onSelect: function (dateStr) {
var min = $(this).datepicker('getDate'); // Get selected date
$("#TextBox2").datepicker('option', 'minDate', min || '0'); // Set other min, default to today
}
});
$("#TextBox2").datepicker({
minDate: '0',
maxDate: '+1Y+6M',
onSelect: function (dateStr) {
var max = $(this).datepicker('getDate'); // Get selected date
$('#datepicker').datepicker('option', 'maxDate', max || '+1Y+6M'); // Set other max, default to +18 months
var start = $("#TextBox1").datepicker("getDate");
var end = $("#TextBox2").datepicker("getDate");
var days = (end - start) / (1000 * 60 * 60 *24);
$("#TextBox3").val(days);
}
});
html :
<p>Date From :
<input type="text" id="TextBox1" /> </p> <p>Date To :
<input type="text" id="TextBox2" /> </p> <p>Difference :
<input type="text" id="TextBox3" /> </p>
i put 01-01-2015 to 31-01-2015 and the result is 1000 month. I dont know why the code make it 1000. Any advise and help from you guys?.....