function data(data) {
data = formatDate(data);
var lc = new Date().setHours(0, 0, 0, 0);// 当前时间的凌晨的时间戳
var nowlc = new Date(lc);
var nowTime = nowlc.getTime();
var nowDay = nowlc.getDay();
var oneDay = 24 * 60 * 60 * 1000;
var Monday = nowTime - (nowDay - 1) * oneDay;
var monday = new Date(Monday);
var mondaytamp = Number(monday); //当前时间周一凌晨的时间戳
var date2 = new Date(data);
var timetamp = Number(new Date(data)); // 转化从时间戳
var differMin = ((lc - date2) / 1000); // 两个时间相差的秒数
if (differMin > 0) {
var min = (differMin / 60).toFixed(0);
var h = (min / 60).toFixed(0);
if (h <= 24) {
data = "昨天"
} else if (h <= 48) {
data = "前天"
} else if (h > 48) {
var d = timetamp - mondaytamp;
if (d >= 0) {
var week = ["日", "一", "二", "三", "四", "五", "六"];
var index = date2.getDay();
data = "周" + week[index]
} else if (d < 0) {
var year = date2.getFullYear();
var month = date2.getMonth();
var day = date2.getDate();
data = year + "/" + p((month + 1)) + "/" + p(day)
}
}
} else {
// 当时时间段 时分
var hour = date2.getHours();
var minute = date2.getMinutes();
data = p(hour) + ":" + p(minute)
}
return data;
}