赞
踩
js对时间日期判断今天昨天明天
let time = function(date) {
let time_str = "";
if (new Date(date).getDate() === new Date().getDate()) {
time_str = "今天";
} else if (new Date(date).getDate() === (new Date().getDate() - 1)) {
time_str = "昨天";
} else if (new Date(date).getDate() === (new Date().getDate() + 1)) {
time_str = "明天";
} else if (new Date(date).getDate() < new Date().getDate()) {
time_str = "过去";
}
return time_str;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。