JQuery datepicker numberOfMonths: display current selection month last

Maton picture Maton · May 31, 2010 · Viewed 9.9k times · Source

I have a jquery datepicker with the numberOfMonths set to 3, currently when I click on the datepicker, the left side month is the current month. In most cases, the user is only going to be selecting a date prior to todays date so I would prefer the current month selected to be the last calendar i.e. March, April, May instead of the current implementation which is May, June, July.

Greatly appreciate any help!

Answer

Nick Craver picture Nick Craver · May 31, 2010

Use the showCurrentAtPos option just for that purpose:

Specify where in a multi-month display the current month shows, starting from 0 at the top/left.

The usage looks like this:

$("#datepicker").datepicker({
    numberOfMonths: 3,
    showCurrentAtPos: 2
});​

Since it's zero-based, 2 would be the right-most, you can see a working demo here.