一、uxsolutions
github:https://github.com/uxsolutions/bootstrap-datepicker
doc:https://bootstrap-datepicker.readthedocs.io/en/stable/index.html
I18N:要引入语言包
$('#datetimepicker1').datepicker({
format: "yyyy-mm-dd",
language: 'zh-CN',
autoclose: true,
endDate:new Date()
}).on('changeDate', function(ev){
if(ev.date){
$('#datetimepicker2').datepicker('setStartDate', new Date(ev.date.valueOf()))
}else{
$('#datetimepicker2').datepicker('setStartDate',null);
}
});
$('#datetimepicker2').datepicker({
format: "yyyy-mm-dd",
language: 'zh-CN',
autoclose: true,
endDate:new Date()
}).on('changeDate', function(ev){
if(ev.date){
$('#datetimepicker1').datepicker('setEndDate', new Date(ev.date.valueOf()))
}else{
$('#datetimepicker1').datepicker('setEndDate',null);
}
});
二、Eonasdan
github:https://github.com/Eonasdan/bootstrap-datetimepicker
doc:http://eonasdan.github.io/bootstrap-datetimepicker/#linked-pickers
$('#datetimepicker1,#datetimepicker2').datetimepicker({
format: "YYYY-MM-DD",
locale: 'zh-cn'
});
$("#datetimepicker1").on("dp.change", function (e) {
$('#datetimepicker2').data("DateTimePicker").minDate(e.date);
});
$("#datetimepicker2").on("dp.change", function (e) {
$('#datetimepicker1').data("DateTimePicker").maxDate(e.date);
});
网友评论