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