Bootstrap date range picker view month and year only

Samsul Arifin picture Samsul Arifin · Mar 25, 2015 · Viewed 11.9k times · Source

i build a form that contain month range. i am using daterangepicker bootstrap to do it. For example from Jan to April, but i cannot display month view only using viewMode: 'months', or may be there is another code to display month only?

This is my js code:

$(function () {
    $('#growthrange').daterangepicker({
        format: 'MM/yyyy',
        viewMode: 'months',
        minViewMode: 'months',
        autoclose: true,

        locale: {
            applyLabel: 'Apply Date',
            fromLabel: 'First Date',
            toLabel: 'Second Date',
            monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
            firstDay: 1
        }
    },
    function (start, end) {
        $('#growthrange span').html(start.toString('MMMM, yyyy') + '-' + end.toString('MMMM, yyyy'));
    });

Help please!

Answer

4givN picture 4givN · Mar 23, 2018

Me too, I tried to find solution but none really work for my context, here's whay I implemented it (with more options & event listener) : Hope this can help others if its too late for the post: enter image description here

See here the git repo (Don't hesitate to contribute)