获取时间戳做了兼容,真机环境正常但是开发版和体验版以及线上版iOS都显示刚刚
2 回复
你的代码看不下去,还做什么系统兼容,建议使用时间戳判断
function prettyDate(data) { //姑且当传入的是日期格式 var diff = ((( new Date()).getTime() - data.getTime()) / 1000), day_diff = Math.floor(diff / 86400); return day_diff == 0 && ( diff < 60 && "刚刚" || diff < 120 && "1分钟前" || diff < 3600 && Math.floor(diff / 60) + "分钟前" || diff < 7200 && "1小时前" || diff < 86400 && Math.floor(diff / 3600) + "小时前" ) || day_diff == 1 && "昨天" || day_diff < 7 && day_diff + "天前" || Math.ceil(day_diff / 7) + "周前" ; } |