layData結束時間大於開始時間,根據開始時間限制結束時間選擇
html
<input id="staDate" type="text" placeholder="年/月/日" /> - <input id="endDate" type="text" placeholder="年/月/日" />
js
let myDate=new Date(), nowy= myDate.getFullYear(), nowm=myDate.getMonth()+1, nowd=myDate.getDate(), nowh=myDate.getHours(), nowmin=myDate.getMinutes(), nows=myDate.getSeconds(), nowDay=nowy+"-"+nowm+"-"+nowd+" "+nowh+":"+nowmin+":"+nows; var startDate=laydate.render({ elem:'#staDate', //指定元素 theme:'#2b579a', format:'yyyy-MM-dd HH:mm:ss', max:nowDay, type:'datetime', done: function(value,dates){ endDate.config.min ={ year:dates.year, month:dates.month-1, //關鍵 date:dates.date, hours:dates.hours, minutes:dates.minutes, seconds:dates.seconds }; } }) var endDate=laydate.render({ elem:'#endDate', format:'yyyy-MM-dd HH:mm:ss', theme:'#2b579a', min:$("#staDate").val(), // max:nowDay, type:'datetime', done: function(value){ } });