JQuery UI Datepicker, reverse the order of the year in the dropdowns

后端 未结 6 523
梦毁少年i
梦毁少年i 2020-12-01 16:58

I have a datepicker with changeyear: true. The \'year\' drop down displays the title as 2009, then instead of the next year below the title being 2008, 2007, 2006 and so on

6条回答
  •  一向
    一向 (楼主)
    2020-12-01 17:24

    There is a "way" to get the year started from the last date:

    dateFormat: 'mm/dd/yy',
    changeMonth: true, 
    changeYear: true,  
    yearRange: "-70:", 
    maxDate: "-13Y"
    

    Instead if using yearRange as fixed years yearRange: "1900:-13" it's better to use this from bottom up: "-70:", and set the maxDate. Now I get my year select box starting from 2004 and not 1900.

    P.S: All the other solutions have been tested. They are very slow, and some don't work so well (especially the old ones - sets current year instead of 2004 for example).

提交回复
热议问题