页面代码我就不粘了,日期时间控键可以去layUI关官方文档查看
本方法适用laydate 5.0.9 新版
var startDate = layui.laydate.render({
elem: '#starttime',
min: '2017-12-28',
type: 'datetime',
//btns: ['confirm'],
done:function(value,date){
if( value !== '' ){
endDate.config.min.year = date.year;
endDate.config.min.month = date.month - 1;
var day = date.date;
if(date.hours == 23 && date.minutes == 59 && date.seconds == 59){
day = day + 1;
}else{
endDate.config.min.hours = date.hours;
endDate.config.min.minutes = date.minutes;
endDate.config.min.seconds = date.seconds;
}
endDate.config.min.date = day;
endDate.config.btns = ['clear','confirm'];
}else{
endDate.config.min.year = '';
endDate.config.min.month = '';
endDate.config.min.date = '';
endDate.config.min.hours = '';
endDate.config.min.minutes = '';
endDate.config.min.seconds = '';
endDate.config.btns = ['clear','now','confirm'];
}
}
});
var endDate = layui.laydate.render({
elem: '#endtime',
min: '2017-12-28',
type: 'datetime',
//btns: ['confirm'],
done:function(value,date){
if( value !== '' ){
startDate.config.max.year = date.year;
startDate.config.max.month = date.month - 1;
var day = date.date;
if(date.hours == 0 && date.minutes == 0 && date.seconds == 0){
day = day - 1;
}else{
startDate.config.max.hours = date.hours;
startDate.config.max.minutes = date.minutes;
startDate.config.max.seconds = date.seconds;
}
startDate.config.max.date = day;
startDate.config.btns = ['clear','confirm'];
}else{
startDate.config.max.year = '';
startDate.config.max.month = '';
startDate.config.max.date = '';
startDate.config.max.hours = '';
startDate.config.max.minutes = '';
startDate.config.max.seconds = '';
startDate.config.btns = ['clear','now','confirm'];
}
}
});