function setTime(data) {
var data = data;
var time = new Date(data);
var yyyy = time.getFullYear();
var mm = time.getMonth()+1;
var dd = time.getDate();
var h = time.getHours();
var min = time.getMinutes();
var second = time.getSeconds();
return {
year:yyyy,
month:mm,
day:dd,
hour:h,
minute:min,
second:second
}
}
//vue过滤器运用
filters:{
time04(val){
var Y,M,D,month;
var date = new Date(val * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
Y = date.getFullYear();
M = (date.getMonth()+1 < 10 ? (date.getMonth()+1) : date.getMonth()+1);
D = date.getDate();
return Y+'-'+M+'-'+D;
}
},
【记录】时间戳转时间
最新推荐文章于 2024-06-08 08:45:00 发布