$('.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格式化:
<input data-format="yyyy-MM-dd hh:mm:ss" type="text"></input>