Search code examples
javascripttwitter-bootstrapdatepickerbootstrap-datepicker

Bootstrap datepicker: Start picking date from year


Normally when selecting dates from immediate vicinity of 'today', default behaviour (picking a day of month) works well but when picking birthdays I want the user to start picking the date from years. I looked at the docs but couldn't find any option to do this. I want the datepicker to open with years selection first. As shown in this picture:

enter image description here

I'm using this plugin: https://bootstrapdatepicker.readthedocs.io/en/latest/


Solution

  • Use startView option (0-days, 1-months, 2-years, see plugin docs):

    $('#date').datepicker({
        startView:2//
    });