标签:int end ptime 时间戳 time() nbsp space ret 差值
function comptime(beginTime) {
var nowtime = (new Date).getTime();
endTime = nowtime;
var secondNum = parseInt((endTime - beginTime * 1000) / 1000); //计算时间戳差值
if(secondNum >= 0 && secondNum < 60) {
return secondNum + ‘秒前‘;
} else if(secondNum >= 60 && secondNum < 3600) {
var nTime = parseInt(secondNum / 60);
return nTime + ‘分钟前‘;
} else if(secondNum >= 3600 && secondNum < 3600 * 24) {
var nTime = parseInt(secondNum / 3600);
return nTime + ‘小时前‘;
} else {
var nTime = parseInt(secondNum / 86400);
return nTime + ‘天前‘;
}
}
php时间戳转时间方法
标签:int end ptime 时间戳 time() nbsp space ret 差值
原文地址:http://www.cnblogs.com/SunSong/p/7136564.html