I already get the difference between two date . Now I need to exclude the weekend and display it in the duration input. For Example : I Choose the date from ( 2 March 2020 ) to (9 March 2020) The duration should display 6 days , because it need to deduct 2 day which is saturday and sunday . 2/
$(document).ready(function(){
$('#FromDate').change(function(){
ToDate.min=document.getElementById('FromDate').value;
var start = new Date (document.getElementById('FromDate').value);
var end = new Date (document.getElementById('ToDate').value);
var duration = new Date();
var different = end.getTime() - start.getTime();
duration = (different/(1000*60*60*24))+1;
document.getElementById('duration').value = duration;
});
$('#ToDate').change(function(){
var start = new Date (document.getElementById('FromDate').value);
var end = new Date (document.getElementById('ToDate').value);
var duration = new Date();
var different = end.getTime() - start.getTime();
duration = (different/(1000*60*60*24))+1;
document.getElementById('duration').value = duration;
});
});