本文介绍了在Bootstrap DateTimePicker中将minDate设置为Today的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Bootstrap DateTime Picker( http://eonasdan.github.io/bootstrap-datetimepicker /),我已经找到了设置minDate的基本选项;但是,为了挽救生命,我无法将其设置为今天.我已经尝试过类似Date()的事情;但是,没有任何效果.有人有什么想法吗?

I'm using Bootstrap DateTime Picker (http://eonasdan.github.io/bootstrap-datetimepicker/) and I've found the basic option to set a minDate; but, I can't get it to set to today to save my life. I've tried things like Date(); but, nothing working. Anyone have any ideas?

示例

    $('#date').datetimepicker({
        pickTime: false,
        icons: {
                time: "fa fa-clock-o",
                date: "fa fa-calendar",
                up: "fa fa-arrow-up",
                down: "fa fa-arrow-down"
            },
        startDate: new Date()
    });

推荐答案

如果使用的是最新版本,则需要设置minDate选项.这是一个 JSFiddle 以及一个有效的示例.希望这会有所帮助.

If you're using the latest version, the minDate option is what you'll need to set. Here is a JSFiddle with a working example. Hope this helps.

$('#date').datetimepicker({
    pickTime: false,
    icons: {
      time: "fa fa-clock-o",
      date: "fa fa-calendar",
      up: "fa fa-arrow-up",
      down: "fa fa-arrow-down"
    },
    minDate: moment()
});

这篇关于在Bootstrap DateTimePicker中将minDate设置为Today的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 01:58