I have two date in html Datefrom and Dateto input text with ddmmyyyy format. I am trying to find out the difference between Datefrom and Dateto in Keyup event of Datefrom.
<input type='text' asp-for="Datefrom " class="form-control " id="Datefrom " />
<input type='text' asp-for="Dateto " class="form-control " id="Dateto " />
I am trying to find out the difference between two date in JavaScript as given below. The difference is not showed as correctly.
<script>
$("#Datefrom").datepicker({ format: 'dd/mm/yyyy', date: new Date(1900, 01, 01), autoclose: true, todayBtn: 'linked' });
$("#Dateto").datepicker({ format: 'dd/mm/yyyy', date: new Date(1900, 01, 01), autoclose: true, todayBtn: 'linked' });
$('#Datefrom ').keyup(function () {
var stdatestring = $('#Datefrom').val();
var missdatestring = $('#Dateto').val();
var stdateval = moment(stdatestring, 'DD/MM/YYYY').toDate();
var datefromval = moment(missdatestring, 'DD/MM/YYYY').toDate();
var diffdate = missdatestring - stdatestring
});
</script>