Why does this work?
<script>
var today = new Date();
var yesterday = new Date(Date.now() - 24*60*60*1000);
from.max = yesterday.toISOString().split("T")[0];
to.max = today.toISOString().split("T")[0];
$(document).ready(function () {
$("#from").change(function () {
var minDate = $("#from").val();
var fromDate = new Date(minDate);
var minToDate = new Date(fromDate - 24*60*60*1000);
$('#to').attr('min', minToDate.toISOString().split("T")[0]);
});
});
</script>
But this does not:
... var minToDate = new Date(fromDate + 24*60*60*1000); ...
The point is to set the minimum date of “to” to the next day of the chosen “from” date. Just for testing purposes I tried the “-” version. And it truly sets the minimum value to the day before the “from” date. But the opposite, which is what I’m looking for, is not working. Crazy! 😀