JSFiddle - React, Tailwind, and code Playground
by Eric Howe
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css">
<p>Choose your dates.</p>
<input type="text" id="arr_date">
<input type="text" id="dep_date">
<input type="text" id="num_nights" readonly>
JavaScript
function showDays() {
var start = $('#arr_date').datepicker('getDate');
var end = $('#dep_date').datepicker('getDate');
if (!start || !end) return;
var days = (end - start) / 1000 / 60 / 60 / 24;
$('#num_nights').val(days);
}
$("#arr_date").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: showDays
});
$("#dep_date").datepicker({
dateFormat: 'dd-mm-yy',
onSelect: showDays
});