var str = 1478508411000; console.log(new Date(str).toDateString()); if (new Date(str).toDateString() === new Date().toDateString()) { //今天 console.log("当天"); } else if (new Date(str) < new Date()){ //之前 console.log(new Date(str).toISOString().slice(0,10)); } 函数形式function isToday(str) { if (new Date(str).toDateString() === new Date().toDateString()) { //今天 console.log("当天"); } else if (new Date(str) < new Date()){ //之前 console.log("以前的日期"); } } var str = 1474172800000; isToday(str);
js判断时间戳是否为当天时间
最新推荐文章于 2025-03-06 09:44:50 发布