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;

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM