Laydate设置开始结束时间[模糊搜索很常用]

 

页面代码我就不粘了,日期时间控键可以去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'];
				}
			}
		});

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值