Bootstrap 4 Bootstrap datetimepicker小部件如何允许无效的mysql日期,如';0000-00-00';?

Bootstrap 4 Bootstrap datetimepicker小部件如何允许无效的mysql日期,如';0000-00-00';?,bootstrap-4,datetimepicker,bootstrap-datetimepicker,Bootstrap 4,Datetimepicker,Bootstrap Datetimepicker,我的Php Mysql应用程序需要在UI中允许并设置一些无效日期,如Mysql默认日期0000-00-00 当我尝试在bootstrap DateTime小部件中执行此操作时,它似乎删除了0000-00-00,并变为空字段。我的代码如下 //do the dates now $("#date").datetimepicker({ format: "YYYY-MM-DD", icons: { time: "fa fa-clock-o", date:

我的Php Mysql应用程序需要在UI中允许并设置一些无效日期,如Mysql默认日期0000-00-00

当我尝试在bootstrap DateTime小部件中执行此操作时,它似乎删除了0000-00-00,并变为空字段。我的代码如下

//do the dates now
$("#date").datetimepicker({
    format: "YYYY-MM-DD",
    icons: {
        time: "fa fa-clock-o",
        date: "fa fa-calendar",
        up: "fa fa-chevron-up",
        down: "fa fa-chevron-down",
        previous: "fa fa-chevron-left",
        next: "fa fa-chevron-right",
        today: "fa fa-screenshot",
        clear: "fa fa-trash",
        close: "fa fa-remove"
    }
});

如何添加/允许选项以允许用户输入无效日期,如“0000-00-00”?

实际上,如果您希望输入0000-00-00,那么将其作为输入日期非常容易。 bootstrap datepicker提供了一个选项,它是forceParse:false

将此选项设置为false会为您带来所有好处,默认情况下为true,但请注意,这会带来巨大的代价;):)

将此选项设置为false,以允许输入任何错误的日期

资料来源:

Type: Boolean
Default: true

Whether or not to force parsing of the input value when the picker is closed. That is, when an invalid date is left in the input field by the user, the picker will forcibly parse that value, and set the input’s value to the new, valid date, conforming to the given format.