1、过滤13位时间戳(以评论时间为例)
1 filters : {
2 formattime2: function (value) {
3 //value为13位的时间戳
4 var timestamp = Date.parse(new Date());
5 var ms = Math.abs(timestamp - value);
6 var second = parseInt(ms / 1000);
7 var minute = parseInt(ms / 1000 / 60);
8 var iHour = parseInt(ms / 1000 / 60 / 60);
9 var day = parseInt(ms / 1000 / 60 / 60 / 24);
10 if(second < 1){
11 return "刚刚";
12 }else if(minute < 60){
13 return minute+"分钟前";
14 }else if(iHour < 24){
15 return iHour+"小时前";
16 }else{
17 return day+"天前";
18 }
19 }
20 },