本方法通过vue.js filter实现将unix时间戳转换为自定义标准时间格式
$().ready(function() {
Vue.filter('time',
function(value) {
var date = new Date(value);
Y = date.getFullYear(),m = date.getMonth() + 1,d = date.getDate(),H = date.getHours(),i = date.getMinutes(),s = date.getSeconds();
if (m < 10) {
m = '0' + m;
}
if (d < 10) {
d = '0' + d;
}
if (H < 10) {
H = '0' + H;
}
if (i < 10) {
i = '0' + i;
}
if (s < 10) {
s = '0' + s;
}
// var t = Y+'-'+m+'-'+d+' '+H+':'+i+':'+s;
var t = Y + '-' + m + '-' + d;
return t;
});)
};