laydate实现设置最小时间为当前时间
当前时间之前的日期不能选择,添加个min,主要代码如下:
var now = new Date();
startTime= laydate.render({
elem: '#test1',
type: 'datetime',
format: 'yyyy-MM-dd HH:mm:ss',
theme: 'molv',
min:now.toLocaleString(),
ready: function(date){
//可以自定义时分秒
this.dateTime.hours=now.getHours();
this.dateTime.minutes=now.getMinutes();
},
done: function(value, date, endDate){
setTimes = value;
startTime.config.max = {
year:date.year,
month:date.month-1,
date: date.date,
hours:this.dateTime.hours,
minutes:this.dateTime.minutes
};
console.log('获取设置的时间',setTimes );
}
});
js得到当前的毫秒
var older = 2019-08-10 11:33:00;
var now = new Date().getTime();
var setTimes = new Date(older).getTime();
if(setTimes < now){
layer.msg('设置时间小于当前时间');
return false;
}