<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. 在.NET中实现彩色光标/动画光标和自定义光标[转]

    下面是完整的例子,可以通过命令行编译即可看到效果. Test.cs using System; using System.Drawing; using System.Windows.Forms; us ...

  2. android数据库操作之直接读取db文件

    在对数据库操作时,常用的有两种方法: 1.在代码中建库.建表: 2.直接将相关库.表建立好,将db文件拷贝至assets目录下:     现在来看看第二种方法:   private String Ge ...

  3. iOS开发UI-利用Quartz2D 实现基本绘图(画三角形、矩形、圆、圆弧)

    1.画三角形  运行结果如下 1.1具体实现步骤 1.1.1首先新建一个project,然后自定义一个view 1.2代码 #import "htingShapeView.h" @ ...

  4. iOS开发——UI篇OC篇&TextField作为搜索框的使用

    TextField作为搜索框的使用 在iOS开发中我们经常会使用到搜索框,但是有的时候系统自带的搜索框不足以满足我吗想要的功能,这个时候我们就可以使用自定义的搜索框实现想要的功能. 今天就简单的介绍一 ...

  5. 进程控制之system函数

    ISO C定义了system函数,但是其操作对系统的依赖性很强.POSIX.1包括了system接口,它扩展了ISO C定义,以描述system在POSIX.1环境中的运行行为. #include & ...

  6. LeetCode: Reverse Words in a String:Evaluate Reverse Polish Notation

    LeetCode: Reverse Words in a String:Evaluate Reverse Polish Notation Evaluate the value of an arithm ...

  7. NopCommerce Html扩展方法Html.Widget

    在Nop中有一个Html扩展的类叫HtmlExtensions,主要源码: public static class HtmlExtensions { #region Admin area extens ...

  8. PHP下获取上个月、下个月、本月的日期(strtotime,date)

    今天写程序的时候,突然发现了很早以前写的获取月份天数的函数,经典的switch版,但是获得上月天数的时候,我只是把月份-1了,估计当时太困了吧,再看到有种毛骨悚然的感觉,本来是想再处理一下的,但是一想 ...

  9. 03 InnoDB锁问题

    InnoDB与MyISAM的最大不同有两点:一是支持事务(TRANSACTION):二是采用了行级锁.行级锁与表级锁本来就有许多不同之处,另外,事务的引入也带来了一些新问题.下面我们先介绍一点背景知识 ...

  10. B - Broken Keyboard (a.k.a. Beiju Text)

    Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well ...