简体   繁体   English

Bootstrap Datepicker:将开始日期更改为明天

[英]Bootstrap Datepicker : Changing start date to tomorrow

I am using the Bootstrap datepicker and the following is my jQuery code: 我正在使用Bootstrap datepicker ,以下是我的jQuery代码:

$('.form_date').datetimepicker({
    language: 'en',
    /* endDate: '+0d', */
    startDate: '+1d',
    weekStart: 1,
    autoclose: 1,
    startView: 2,
    format: 'dd/mm/yyyy',
    minView: 2,
    forceParse: 0,
});

The following is what I get: 以下是我得到的:

在此处输入图片说明

I want have the start date highlighting on tomorrow according to our requirement. 我想根据我们的要求在明天突出显示开始日期。 I have found one option defaultViewDate on the Bootstrap datepicker documentation. 我在Bootstrap datepicker文档中找到了一个选项defaultViewDate ( http://bootstrap-datepicker.readthedocs.org/en/latest/options.html ) http://bootstrap-datepicker.readthedocs.org/en/latest/options.html

It states that I have to set the year , month , and day key of defaultViewDate . 它指出我必须设置defaultViewDateyearmonthday键。 But I don't know how to set it. 但是我不知道如何设置。

Try following; 尝试跟随;

$('.form_date').datetimepicker({
    defaultViewDate: { year: 1977, month: 04, day: 25 }
});

It should be in the format of Object with year, month and day keys. 它应该是带有年,月和日键的对象格式。 For more information please see here; 有关更多信息,请参见此处。

https://eternicode.github.io/bootstrap-datepicker https://eternicode.github.io/bootstrap-datepicker

Your format for the startDate option looks correct, but I do see some other errors in your JavaScript that may be confusing the DatePicker (and causing your startDate to be ignored): 您的startDate选项的格式看起来正确,但是我的确在JavaScript中看到其他一些错误,这些错误可能会使DatePicker感到困惑(并导致忽略startDate ):

  1. The autoclose option should be formatted as a Boolean and should be either true or false . 自动autoclose选项的格式应为Boolean并且可以为truefalse
  2. The minView option that you have defined should actually be: minViewMode . 您定义的minView选项实际上应该是: minViewMode
  3. The forceParse option should be formatted as a Boolean and should be either true or false . forceParse选项的格式应为Boolean并且可以为truefalse
  4. You have a trailing comma that follows your final option ( forceParse ), which should be removed so that there is no comma after the final option. 您在最终选项( forceParse )后面有一个逗号,应将其删除,以使最终选项后没有逗号。

If you correct the problems listed above, I believe you will begin to see a correct startDate . 如果您纠正了上面列出的问题,我相信您将开始看到正确的startDate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM