js 中時間相減

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("");

}
 

摘自  夕諾

發佈留言