Bootstrap date range picker view month and year only

眉间皱痕 提交于 2020-01-04 13:27:23

问题


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!


回答1:


How about

This code:

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



回答2:


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:

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



来源:https://stackoverflow.com/questions/29244590/bootstrap-date-range-picker-view-month-and-year-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!