I have two datetimepicker
for a date which is considered as From Date &
To date. I am using eonasdan datetimepicker
of Bootstrap.
I want to set the next 3 month from current date to date. If I use
maxdate:'+90d' and maxdate:'+3M',but it is not work properly. In below snippet I comment maxDate
:
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<script>
function share() {
$("#myModal").modal('show');
}
</script>
<div class="container">
<div class="row">
<button type="button" name="share_video" class="btn btn-default" onclick="share()">Share</button>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<center>
<h4 class="modal-title">Share</h4>
</center>
</div>
<div class="modal-body">
<form action="#" method="post" style="padding: 1px 30px !important;">
<div class="form-group">
<label class="col-md-12">Duration</label>
<div class="col-md-12">
<label class="col-md-12">From</label>
<div class="col-md-6" id=''>
<input type="text" name="FromDate" id="FromDate" class="form-control" name="setTodaysDate" placeholder="MM/DD/YYYY"></div>
<div class="col-md-6">
<input type="text" name="TimeTO" class="form-control col-md-12" id="TimeFrom" placeholder="HH:MM"></div>
</div>
<div class="col-md-12">
<label class="col-md-12">To</label>
<div class="col-md-6" id=''>
<input type="text" id="ToDate" class="form-control" name="setTodaysDate" placeholder="MM/DD/YYYY"></div>
<div class="col-md-6">
<input type="text" name="TimeFrom" class="form-control col-md-12" id="TimeTO" placeholder="HH:MM"></div>
</div>
</div>
<div class="row form-group col-md-12"></div>
<div class="form-group">
<center><button type="submit" name="submit" class="btn btn-default" style="border:none;color:#FFFFFF; background:#2DADBA;">Submit</button></center>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$('#FromDate,#ToDate').datetimepicker({
format: 'L',
format: 'YYYY-MM-DD',
useCurrent: true,
minDate: moment(),
//maxdate:'+3M'
//maxdate:'+90d'
});
$('#FromDate').datetimepicker().on('dp.change', function(e) {
var incrementDay = moment(new Date(e.date));
incrementDay.add(1, 'days');
$('#ToDate').data('DateTimePicker').minDate(incrementDay);
$(this).data("DateTimePicker").hide();
});
$('#ToDate').datetimepicker().on('dp.change', function(e) {
var decrementDay = moment(new Date(e.date));
decrementDay.subtract(1, 'days');
$('#FromDate').data('DateTimePicker').maxDate(decrementDay);
$(this).data("DateTimePicker").hide();
});
});
</script>
</div>