vue 格式化时间戳

var app = new Vue({//商品信息
el : ‘#order’,
data : {
order : [],
product:[]
},
filters: {
formatDatetwo: function (time) {
var re = /-?\d+/;
var m = re.exec(time);
var d = new Date(parseInt(m[0]));
var o = {
“M+”: d.getMonth() + 1, //month
“d+”: d.getDate(), //day
“h+”: d.getHours(), //hour
“m+”: d.getMinutes(), //minute
“s+”: d.getSeconds(), //second
“q+”: Math.floor((d.getMonth() + 3) / 3), //quarter
“S”: d.getMilliseconds() //millisecond
}
var format = “yyyy-MM-dd hh:mm”;
if (/(y+)/.test(format)) {
format = format.replace(RegExp. 1,(d.getFullYear()+"").substr(4RegExp. 1 , ( d . g e t F u l l Y e a r ( ) + "" ) . s u b s t r ( 4 − R e g E x p . 1.length));
}
for (var k in o) {
if (new RegExp(“(” + k + “)”).test(format)) {
format = format.replace(RegExp. 1,RegExp. 1 , R e g E x p . 1.length == 1 ? o[k] : (“00” + o[k]).substr((“” + o[k]).length));
}
}
return format;
}
}
});

你可能感兴趣的:(问题记录)