twitter-bootstrap Bootstrap datetimepicker startDate 和 EndDate
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37973683/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap datetimepicker startDate and EndDate
提问by Sanduni Di
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);
});
采纳答案by fjsuarez
Read the docs at http://eonasdan.github.io/bootstrap-datetimepicker/Options/#mindate
在http://eonasdan.github.io/bootstrap-datetimepicker/Options/#mindate阅读文档
There are no options called setStartDateor setEndDate.
没有称为setStartDate或 的选项setEndDate。
You should use minDateand maxDate. For these options you can use date, moment, or string.
你应该使用minDate和maxDate。对于这些选项,您可以使用date,moment或string。
Here is a working jsfiddlewith said options.
这是一个带有上述选项的有效jsfiddle。
Edit. Also note that using new Date()will return the current time, so that should set your start date to today.
编辑。另请注意, usingnew Date()将返回当前时间,因此应将您的开始日期设置为今天。
回答by Sumit Kumar Gupta
You should use minDate and maxDate for this features
您应该为此功能使用 minDate 和 maxDate
$(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,
});
});

