I'm wish to get the date value from the datetimepicker (http://eonasdan.github.io/bootstrap-datetimepicker/) using jquery to find the difference between 2 input dates. I had spent days to do it but no luck at all. Here are my code:
HTML
<div class="col-sm-4">
<label for="label_duration" id="lblStartDate"
class="col-sm-2 control-label">Start Date</label>
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" name="startdate"
id="startdate" placeholder="yyyy-mm-dd" required/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<div class="col-sm-4">
<label for="label_duration" id="lblEndDate" class="col-sm-2
control-label">End Date</label>
<div class='input-group date' id='datetimepicker2'>
<input type='text' class="form-control" name="enddate" id="enddate"
placeholder="yyyy-mm-dd" required/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
jQuery
$(function () {
$('#datetimepicker1').datetimepicker({
viewMode: 'years',
format: 'YYYY-MM-DD'
});
$('#datetimepicker2').datetimepicker({
viewMode: 'years',
format: 'YYYY-MM-DD'
});
});
Diff in days between two strings:
Diff in days between your two inputs: