【发布时间】:2019-07-23 02:37:17
【问题描述】:
我在我的流星应用程序中使用了 Gijgo DateTimePicker,使用 by react。它运作良好。现在我正在尝试禁用所有过去的日期。我在这个docs 中找到了 disableDates 选项。但是有一个选项可以禁用特定日期。如何使用datetimepicker 禁用所有过去的日期?因为我需要日期和时间。
Gijgo 示例:1
<input id="datepicker" width="312" />
<script>
$('#datepicker').datepicker({
value: '11/10/2017',
disableDates: [new Date(2017,10,11), '11/12/2017']
});
</script>
Gijgo 示例:2
<script>
$('#datepicker').datepicker({
value: '11/11/2017',
disableDates: function (date) {
var disabled = [10,15,20,25];
if (disabled.indexOf(date.getDate()) == -1 ) {
return true;
} else {
return false;
}
}
});
</script>
我的代码:
$("#dateTime").datetimepicker({
format: "ddd, mmm d, yyyy h:MM TT",
uiLibrary: "bootstrap4",
iconsLibrary: "fontawesome",
modal: true,
footer: true,
//value: "03/01/2019",
disableDates: function(date) {
const currentDate = new Date();
return date > currentDate ? true : false;
}
});
【问题讨论】:
标签: javascript reactjs date meteor datepicker