<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. 线性求中位数 poj2388

    在做uva11300时,遇到了n < 1000 000的中位数,就看了一下线性求中位数. 该算法的最差时间复杂度为O(N^2),期望时间复杂度为O(N),证明推理详见算法导论P110. 和快排的 ...

  2. ERROR 1227 (42000): Access denied; you need (at least one of) the PROCESS privilege(s) for this oper

    1  用以往的mysql登陆模式登陆 [mysql@eanintmydbc002db1 mysqllog]$ mysql Enter password:  Welcome to the MySQL m ...

  3. Java 开源博客——B3log Solo 0.6.6 正式版公布了!

    Java 开源博客 -- B3log Solo 0.6.6 正式版公布了!欢迎大家下载. 该版本号引入了数据库连接池:Druid. 另外,欢迎观摩 B3log 团队的新项目:Noty,也很欢迎大家參与 ...

  4. 几种流行Webservice框架性能对照

     转自[http://blog.csdn.net/thunder4393/article/details/5787121],写的非常好,以收藏. 1      摘要 开发webservice应用程序中 ...

  5. Flex4之元数据标签使用

    Flex 元数据标签 1.[ArrayElementType] 使用ArrayElementType元数据标签可以让你定义数组元素的数据类型. 程序代码: [ArrayElementType(&quo ...

  6. online ddl 使用、测试及关键函数栈

    [MySQL 5.6] MySQL 5.6 online ddl 使用.测试及关键函数栈  http://mysqllover.com/?p=547 本文主要分为三个部分,第一部分是看文档时的笔记:第 ...

  7. Hidden Markov Model

    Markov Chain 马尔科夫链(Markov chain)是一个具有马氏性的随机过程,其时间和状态参数都是离散的.马尔科夫链可用于描述系统在状态空间中的各种状态之间的转移情况,其中下一个状态仅依 ...

  8. win7配置nginx + php

    nginx的下载地址:  http://www.nginx.cn/nginx-download 在nginx下创建文件php-cgi.cmd,并写入内容: "D:\nginx_php-5.6 ...

  9. iOS 除去图片的白色背景(接近白色),或者其它颜色的替换,获取像素点的ARGB值

    iOS 除去图片的白色背景(接近白色),或者其它颜色的替换 方法如下: //去除图片的白色背景 + (UIImage*) imageToTransparent:(UIImage*) image { / ...

  10. javaScript入门--引用类型

    前面提到过,引用类型的值便是对象,在ECMAScript中,引用类型是一种数据结构,用于将数据和功能组织在一起,而对象则是某个特定引用类型的实例. var a=new Object(); 上面便声明了 ...