当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - 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

});

}

网友答案:
$('#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/

分享给朋友:
您可能感兴趣的文章:
随机阅读: