var IssuedTime=new Date(selectRows.IssuedTime); //计划下发年月日小时 var IssuedYear = IssuedTime.getFullYear(); var IssuedMonth = IssuedTime.getMonth()+1; var IssuedDate = IssuedTime.getDate(); var IssuedHours = IssuedTime.getHours(); var date = new Date(); //当前时间年月日小时 var NowYear = date.getFullYear(); var NowMonth = date.getMonth()+1; var NowDate = date.getDate(); var NowHours = date.getHours(); //时间比较 if (IssuedTime < date) { $.messager.alert(‘提示信息‘, "已经超过计划发布日期,请确认!"); return; } //时间计算 // 给日期类对象添加日期差方法,返回日期与diff参数日期的时间差,单位为天 //return (this.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); debugger; var IssH = (IssuedTime - date) / (60 * 60 * 1000);
原文:http://www.cnblogs.com/lhlong/p/6971710.html