Bootstrap Datepicker re-initialize date format

后端 未结 3 568
执念已碎
执念已碎 2021-01-14 18:51

I have Bootstrap datepicker with default format mm/dd/yyyy, and I have select where I can change format from mm/dd/yyyy to dd/mm/yy

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-14 19:19

    Ok I resolve this extending bootstra-datepicker.js

    setFormat: function(format) {
        this.format = DPGlobal.parseFormat(format);
    }
    

    And call that function

    find('#options-date_format').on('change', function(){
        $("#picker").datepicker('setFormat', newFormat);
    });
    

提交回复
热议问题