var addDate = "获取到你想要的时间";//注意时间格式是:2012-03-05 11:41:30.910 addDate = new Date(Date.parse(addDate.replace(/\-/g, "/"))); var now = new Date(); var diff = now.getTime() - addDate.getTime(); //判断大于七天 if (addDate == 'NaN' || diff > 0 && diff > 7 * 24 * 60 * 60 * 1000) { art(""); }
转载于:https://www.cnblogs.com/wang-123/archive/2012/03/08/2385272.html