I know this question has been asked before, but I could not find anything close to what I am trying to do. I am using jQuery Datepicker http://keith-wood.name/datepick.html and using the range with 2 calendars. In my app I have a service that I charge a 1 day price for. What I want to do is offer the end user a date range to pick how many days they would like to purchase and show them the total. To get me started, I just want to know how to calculate the amount of days selected in the range.
Here is my code:
<?php
// this has the css and javascript includes
include('includes/header.php');
?>
<div class="container">
<div class="row">
<div class="span3"></div>
<div class="span9">
<form>
<div class="controls">
<input id="range2Picker" name="range2Picker" value="" class="input-large" required="" type="text">
</div>
</form>
</div>
</div>
</div>
<script>
$('#range2Picker').datepick({
date1 = new Date(date1);
date2 = new Date(date2);
rangeSelect: true,
monthsToShow: 2,
changeMonth: false,
minDate: +3,
onClose: function(date1, date2) {
var timediff = date2 - date1;
alert('Number of days are: ' + timediff);
}
});
</script>