Solution 1 :

Try this.

$(document).ready(function(){

    $("#datepicker-month").datepicker( {
        format: "mm-yyyy",
        viewMode: "months", 
        minViewMode: "months"
    });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>


<input type="text" id="datepicker-month" />

Solution 2 :

Hope this will help you:

$('#you-date-picker-element').datepicker({
    autoclose: true,
    minViewMode: 1,
    orientation: 'left',
    container: '.your-date-picker-container',
    format: 'M-yyyy'
}).on('changeDate', function(selected){
    startDate = new Date(selected.date.valueOf());
    startDate.setDate(startDate.getDate(new Date(selected.date.valueOf())));
    $('#your-field-name').datepicker('setStartDate', startDate);
}); 

Problem :

Hello I have a problem with the datepicker. I see the days and not only the months I mean instead of having this :

datepicker

I get this :

datepicker

Here is my code :

 <input type="text" id="datepicker" />

and here is the js :

$("#datepicker").datepicker( {
    format: "mm-yyyy",
    viewMode: "months", 
    minViewMode: "months"
});

Could you help me please ?

Thank you very much !

Comments

Comment posted by Peter

No because I mean I want the following format :

Comment posted by souravmsh

Rename the datepicker id I think datepicker already implemented by this id. write #datepicker-month instead of #datepicker

Comment posted by Peter

It changes nothing :/

Comment posted by stackoverflow.com/a/14974623/9042437

you can look here

Comment posted by Peter

It changes nothing :/

Comment posted by github.com/uxsolutions/bootstrap-datepicker

Please try with the above bootstrap-datepicker libraries or you can download it

Comment posted by Roko C. Buljan

@Peter

Comment posted by Peter

Unfortunately I get the same problem :/

Comment posted by bootstrap-datepicker.readthedocs.io/en/latest/…

did you add

By