function isToday(str) {
var d = new Date(str.replace(/-/g, "/"));
var todaysDate = new Date();
if (d.setHours(0, 0, 0, 0) == todaysDate.setHours(0, 0, 0, 0)) {
return true;
} else {
return false;
}
}
by default7#zbphp.com
自己修改,增加diff参数。 diff为天数
function isToday(str, diff) {
var d = new Date(str.replace(/-/g, "/"));
var todaysDate = new Date();
if (!isNaN(diff)) {
d.setDate(d.getDate() + diff);
}
if (d.setHours(0, 0, 0, 0) == todaysDate.setHours(0, 0, 0, 0)) {
return true;
} else {
return false;
}
}