Reputation:
I want to allow only selectable date on calender, start date as today date and end date as 'end; below is my code, its not working pls advice
$(function() {
var start = $('#start').val();
var end = $('#end').val();
$('#datepicker').datetimepicker(
'setStartDate': today,
'setEndDate':end);
});
Upvotes: 4
Views: 15968
Reputation: 2364
You should use minDate and maxDate for this features
$(function() {
var start = '20-Aug-2019 10:05';
var end = '30-Sep-2019 10:05';
$('#datepicker').datetimepicker({
format : 'DD-MMM-YYYY HH:mm',
minDate: today,
maxDate:end,
});
});
Upvotes: 0
Reputation: 301
Read the docs at http://eonasdan.github.io/bootstrap-datetimepicker/Options/#mindate
There are no options called setStartDate
or setEndDate
.
You should use minDate
and maxDate
. For these options you can use date
, moment
, or string
.
Here is a working jsfiddle with said options.
Edit. Also note that using new Date()
will return the current time, so that should set your start date to today.
Upvotes: 5