简体   繁体   中英

Bootstrap Datepicker : Changing start date to tomorrow

I am using the Bootstrap datepicker and the following is my jQuery code:

$('.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. ( http://bootstrap-datepicker.readthedocs.org/en/latest/options.html )

It states that I have to set the year , month , and day key of defaultViewDate . 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

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):

  1. The autoclose option should be formatted as a Boolean and should be either true or false .
  2. The minView option that you have defined should actually be: minViewMode .
  3. The forceParse option should be formatted as a Boolean and should be either true or false .
  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.

If you correct the problems listed above, I believe you will begin to see a correct startDate .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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