var time = '2017年06月02日 10:43:24';
// 时间统一函数
function getTimeText(argument) {
var timeS = argument;
var todayT = ''; //
var yestodayT = '';
var timeCha = getTimeS(timeS);
timeS = timeS.slice(-8);
todayT = new Date().getHours()*60*60*1000 + new Date().getMinutes()*60*1000 + new Date().getSeconds()*1000;
yestodayT = todayT + 24*60*60*1000;
if(timeCha > yestodayT) {
return argument.slice(0,11);
}
if(timeCha > todayT && timeCha < yestodayT) {
return timeS.slice(0,2)>12?'昨天 下午'+(timeS.slice(0,2)==12 ? 12 : timeS.slice(0,2) - 12)+timeS.slice(2,5):'昨天 上午'+timeS.slice(0,5);
}
if(timeCha < todayT) {
return timeS.slice(0,2)>=12?'下午'+(timeS.slice(0,2)==12 ? 12 : tim
js仿照聊天记录的时间显示 今天 昨天
最新推荐文章于 2025-04-02 13:46:05 发布