Bootstrap Datepicker : Changing start date to tomorrow

天涯浪子 提交于 2019-12-08 04:11:29

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/28322680/bootstrap-datepicker-changing-start-date-to-tomorrow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!