日期:2014-05-16  浏览次数:20442 次

js 指定时间与当前时间做比较
jQuery.extend($.fn.fmatter, {
		fmatterNotice : function (cellvalue, options, rowObject) { // 格式化状态值
			var nowDate = new  Date(); 
			var noticeDate = rowObject.NOTICE_DATE;
			var validityDate = rowObject.VALIDITY_DATE;
			
			noticeDate=noticeDate.replace(/-/g,"/");//替换字符,变成标准格式
			var _noticeNewDate=new Date(Date.parse(noticeDate));
			var year1=_noticeNewDate.getFullYear();
			var month1=_noticeNewDate.getMonth();
			var day1=_noticeNewDate.getDate();
			var noticeNewDate=new Date(year1,month1,day1,15,00,00);
			
			validityDate=validityDate.replace(/-/g,"/");//替换字符,变成标准格式
			var _validityNewDate=new Date(Date.parse(validityDate));
			var year2=_validityNewDate.getFullYear();
			var month2=_validityNewDate.getMonth();
			var day2=_validityNewDate.getDate();
			var validityNewDate=new Date(year2,month2,day2,15,00,00);
			if((nowDate.valueOf()>=noticeNewDate.valueOf()) &&  (nowDate.valueOf()<=validityNewDate.valueOf()))
			{
 				return "<font color='green'>即将到期</font>";
			}else if(nowDate.valueOf() > validityNewDate.valueOf()){
				return "<font color='red'>已过期</font>";
			}else{
				return "<font color='#aacc28'>即将提醒</font>";
			}
		}
	});
?

在jqgrid表单上。

?

?