Return last day of last month when using Bootstrap Datepicker to select month

I want to use Bootstrap datepicker to just select month, but it always return the last day of last month, for example, if I select Jan. 2016, it returns 12-31-2015, I want to get the first day of the month I selected.

My code:

if ($(this).hasClass('month-only')) {
      $(this).prop('readonly', true).datepicker({
        format: 'yyyy-mm',
        viewMode: 'months',
        minViewMode: 'months',
        autoclose: true
      });
    }

Solution 1:

Hmm, the above answer doesn't set the date to the end of the month in the jsfiddle link. If anyone is still looking for an answer, I provided an updated answer on this post here: bootstap Datepicker : set value as last day of the month not working

You need to use the 'changeDate' event and the the 'update' method to set the date how you would like to avoid the default first day of month.