Bootstrap datepicker — How to get toDisplay in other format and toValue in other format too

前端 未结 2 909
醉梦人生
醉梦人生 2021-01-14 17:54

For a long time, I\'m having trouble with toValue and toDisplay. I need and appear on the display to show the date in format dd.mm.yyyy an

2条回答
  •  日久生厌
    2021-01-14 18:25

     $("#elementID").datepicker({
            format: "dd/mm/yyyy", // or what ever format your want
            calendarWeeks: true,
            todayHighlight: true,
            clearBtn: true,
            autoclose: true
        });
    

    Include moment.js library in your page then

    var date = moment($('#elementID').datepicker("getDate")).format("YYYY/MM/DD");
    

提交回复
热议问题