问题描述:

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

});

}

网友答案:
$('#input').datepicker({
    minViewMode: 1,
    format: 'yyyy-mm-dd',
    autoclose: true
});

should work https://jsfiddle.net/z56j2eod/3/

or if you want only yyyy-mm your code just works https://jsfiddle.net/z56j2eod/4/

相关阅读:
Top