bootstrap datetimepicker 两个日历写开始结束日期(改善方法) 2018-04-24

image.png
image
        $('.date_start').datetimepicker({
            language:  'zh-CN',
            weekStart: 1,
            todayBtn:  1,
            autoclose: 1,
            showMeridian: true,
            todayHighlight: 1,
            startView: 2,
            minView: 2,
            forceParse: 0,
            endDate: new Date()
        }).on('hide', function(event) {
            event.preventDefault();
            event.stopPropagation();
            $('.date_end').datetimepicker('setStartDate',$('.date_start').data("datetimepicker").getDate());
            //$('.date_end').val("");
        });
        $('.date_end').datetimepicker({
            language:  'zh-CN',
            weekStart: 1,
            todayBtn:  1,
            autoclose: 1,
            showMeridian: true,
            todayHighlight: 1,
            startView: 2,
            minView: 2,
            forceParse: 0,
            endDate: new Date()
        }).on('hide', function(event) {
            event.preventDefault();
            event.stopPropagation();
            $('.date_start').datetimepicker('setEndDate',$('.date_end').data("datetimepicker").getDate());
        });

补充内容:[bootstrap-datetimepicker 如何获取值(日期)

  • 方法一:$("#startTime").data("datetimepicker").getDate()
  • 方法二:$("#startTime").find("input").val();
  • js下格式化: var date = $("#startTime").data("datetimepicker").getDate(), formatted = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours + ":" + date.getMinutes() + ":" + date.getSeconds(); alert(formatted);
  • data-format格式化:

你可能感兴趣的:(bootstrap datetimepicker 两个日历写开始结束日期(改善方法) 2018-04-24)