Search code examples
c#bootstrap-4datepicker

datepicker How to show more years?


I am using bootstrap datepicker and when I open the dropdown to change the year, it shows only 20 years... The current year.. 10 years before and 10 after.

How can I change it and make it show 40 years.. ? the current year ,20 before and 10 after?

Is that posible?

This is what I have setted

 $(".datepicker").datepicker({
     changeMonth: true,
     changeYear: true,
 });
 $(".datepicker").datepicker("option", "showAnim", "clip");

This is the format I have

enter image description here Thanks


Solution

  • $(".datepicker").datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "-20:+10" // 20 years before and 10 years after the current year
    });
    $(".datepicker").datepicker("option", "showAnim", "clip");
    

    you can use the yearRange