<script src="$!webPath/resources/js/laydate/laydate.js"></script>
<script src="$!webPath/resources/js/ajaxfileupload.js"></script>
<script src="$!webPath/resources/js/jquery.zh.cn.js" charset="utf-8"></script>
<script>
jQuery(document).ready(function(){ jQuery.validator.methods.amount = function(e) {
var coupon_order_amount=jQuery("#coupon_order_amount").val();
var coupon_amount=jQuery("#coupon_amount").val();
if(parseInt(coupon_order_amount) > parseInt(coupon_amount)){
return true;
}else{
return false;
}
}; jQuery("#theForm").validate({
rules:{
coupon_description:{required:true},
coupon_name:{required:true},
coupon_begin_time:{required:true},
coupon_end_time:{required:true,endTime:"#coupon_begin_time"},
coupon_count:{digits:true},
coupon_amount:{required:true},
coupon_img:{accept:"图片格式只能为$!config.imageSuffix"},
coupon_order_amount:{required:true,digits:true}
},
messages:{
coupon_description:{required:"优惠券信息描述不能为空"},
coupon_name:{required:"优惠券名称不能为空"},
coupon_begin_time:{required:"开始时间不能为空"},
coupon_end_time:{required:"结束时间不能为空",endTime:"结束日期必须大于开始日期"},
coupon_count:{digits:"优惠券只能为整数"},
coupon_amount:{required:"优惠券金额不能为空"},
coupon_img:{accept:"图片格式只能为$!config.imageSuffix"},
coupon_order_amount:{required:"可使用订单金额不能为空",digits:"可使用订单金额只能为整数",min:"可使用订单金额必须大于优惠券金额",amount:"可使用订单金额必须大于优惠券金额"}
},
submitHandler:function(){
var params = jQuery("#theForm").serializeArray();
var formData= {};
jQuery.each(params, function(i, param){
formData[param.name] = param.value;
});
jQuery(".seller_save").attr("disabled","disabled");
jQuery.ajaxFileUpload({
url:'$!webPath/seller/coupon_save.htm',
dataType:'json',
fileElementId:['coupon_img'],
data:formData,
success:function(data){
var lin = ""+data.url;
if(data.ret==true){
showDialog("msg_info","",data.op_title,0,"succeed",3,function(arg){window.location.href=arg},lin,function(){
window.location.href = "$!webPath/seller/coupon.htm";
});
}
jQuery(".seller_save").removeAttr("disabled");
}
});
}
});
var isIE = ((navigator.userAgent.indexOf("compatible") > -1 && navigator.userAgent.indexOf("MSIE") > -1 && !isOpera)||navigator.userAgent.indexOf("Trident") > -1)?true:false;
jQuery.validator.methods.endTime = function(value, element, param) { debugger; var startDate = jQuery("#coupon_begin_time").val(); var date1=new Date(Date.parse(startDate)); var date2=new Date(Date.parse(value)); if(isIE){ date1 = new Date(Date.parse(startDate.replace("-", "/"))); date2 = new Date(Date.parse(value.replace("-", "/"))); } return date1 <= date2; };
});

具体间隔天数的比较

var isIE = ((navigator.userAgent.indexOf("compatible") > -1 && navigator.userAgent.indexOf("MSIE") > -1 && !isOpera)||navigator.userAgent.indexOf("Trident") > -1)?true:false;
function timeRule(cur){
if(parseInt(cur)<10){
cur = "0"+cur;
}
return cur
}
function curDate(){
var date = new Date(),
year = date.getFullYear(),
mouth = date.getMonth()+1,
datec = date.getDate(),
hour = date.getHours(),
minite = date.getMinutes(),
seconds = date.getSeconds(),
millsieconds = date.getMilliseconds(); mouth = timeRule(mouth);
datec = timeRule(datec);
hour = timeRule(hour);
minite = timeRule(minite);
seconds = timeRule(seconds); return (year+'-'+mouth+"-"+datec+" "+hour+":"+minite+":"+seconds)
} jQuery.each(jQuery('.coupon-card.active'),function(i,item){
var startTime = curDate(),
endTime = jQuery(item).find('.s-end-time').text(),
date1 = new Date(Date.parse(startTime)),
date2 = new Date(Date.parse(endTime));
if(isIE){
date1 = new Date(Date.parse(startTime.replace("-", "/")));
date2 = new Date(Date.parse(endTime.replace("-", "/")));
}
if(((date2-date1)/(1000*60*60*24))<3){
jQuery(item).removeClass('active').addClass('must-use');
};
})

  

  

javascript笔记——date以及datetime的比较的更多相关文章

  1. Java 和 Javascript 的 Date 与 .Net 的 DateTime 之间的相互转换

    Java 和 Javascript 的 Date 对象内部存放的是从1970年1月1日0点以来的毫秒值. .Net 的 DateTime 对象内部存放的是从0001年1月1日12点以来的tick值,1 ...

  2. [Effective JavaScript 笔记] 第5条:避免对混合类型使用==运算符

    “1.0e0”=={valueOf:function(){return true;}} 是值是多少? 这两个完全不同的值使用==运算符是相等的.为什么呢?请看<[Effective JavaSc ...

  3. [Effective JavaScript 笔记]第27条:使用闭包而不是字符串来封装代码

    函数是一种将代码作为数据结构存储的便利方式,代码之后可以被执行.这使得富有表现力的高阶函数抽象如map和forEach成为可能.它也是js异步I/O方法的核心.与此同时,也可以将代码表示为字符串的形式 ...

  4. [Effective JavaScript 笔记]第28条:不要信赖函数对象的toString方法

    js函数有一个非凡的特性,即将其源代码重现为字符串的能力. (function(x){ return x+1 }).toString();//"function (x){ return x+ ...

  5. python中date、datetime、string的相互转换

    import datetime import time string转datetime str = '2012-11-19' date_time = datetime.datetime.strptim ...

  6. javascript中Date对象的应用——简易日历的实现

    × 目录 [1]效果 [2]HTML [3]CSS[4]JS 前面的话 简易日历作为javascript中Date对象的常见应用,用途较广泛.本文将详细说明简易日历的实现思路 效果演示 HTML说明 ...

  7. JavaScript的Date对象

    整理了一些JavaScript时间的对象,如下所示: toLocaleString()得到当前的年月日和时间的字符串 toLocaleTimeString() 得到当前的时间字符串 toLocaleD ...

  8. Javascript日期与C# DateTime 转换

    DateTime的日期到了客户端为:"/Date(1346818058450+0800)/"; 转吧: var renderTime = function (dateTime) { ...

  9. [Effective JavaScript 笔记] 第4条:原始类型优于封闭对象

    js有5种原始值类型:布尔值.数字.字符串.null和undefined. 用typeof检测一下: typeof true; //"boolean" typeof 2; //&q ...

随机推荐

  1. 我所经历的SAP选型

    这是一个失败的选型项目,而且在可遇见的未来公司也不会再经历SAP选型,甚至不会再启动erp项目,个中原因很难一言道尽,在此简要的说说我们的选型过程以及在选型过程中对各种因素的考虑. 一.重启选型工作七 ...

  2. Java模拟登录系统抓取内容【转载】

    没有看考勤的习惯,导致我的一天班白上了,都是钱啊,系统也不发个邮件通知下....     为了避免以后还有类似状况特别写了个java模拟登录抓取考勤内容的方法(部分代码来自网络),希望有人修改后也可以 ...

  3. 第29题:推断一个序列是否是还有一个push序列的pop序列

    github:https://github.com/frank-cq/MyTest 第29题:输入两个整数序列,当中一个序列表示栈的push顺序,推断还有一个序列有没有可能是相应的pop顺序.为了简单 ...

  4. 怎样破解邮箱password

    破解邮箱password怎样破解邮箱password邮箱在我们的生活中日益成为一个不可或缺的角色.公司与公司之间的商贸往来,学生与老师间的学习交流,以及占非常大部分的私人信件的往来等等非常难离开它.但 ...

  5. 初步认知MySQL metadata lock(MDL)

    http://blog.itpub.net/26515977/viewspace-1208250/ 概述 随着5.5.3引入MDL,更多的Query被“Waiting for table metada ...

  6. NetBeans 安装Android 开发环境

    基本的开发环境都是Eclipse + Android SDK + Android plugin for Eclipse NetBeans下开发Android的所需要的基本条件:NetBeans(包含J ...

  7. CentOS 6.4 安装 thrift-0.9.3

    前言 为了能给.NET的程序提供HBase访问接口需要在Hadoop/Spark集群上安装Thrift Thrift介绍 Thrift是一个软件框架,用来进行可扩展且跨语言的服务的开发.它结合了功能强 ...

  8. Android XML文件布局各个属性详解

    第一常用类:属性值为true或false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 android: ...

  9. PHP.5-DIV+CSS布局网站首页实例

    DIV+CSS布局网站首页实例 网站页面布局 http://www.sj33.cn/digital/wyll/201501/42379.html[页头.页脚.侧边栏和内容区域] #避免各浏览器对CSS ...

  10. ASP.NET获取URL

    //获取完整url (协议名+域名+站点名+文件名+参数) string fullUrl = Request.Url.ToString(); //获取客户端请求的URL信息(不包括主机和端口) str ...