columns:
{
title:'日期',
align:"center",
dataIndex: 'time',
customRender: (text) => {
return !text ? "" : this.DateFormat(text);
}
},
methods:
即可将时间格式化为:YYYY-MM-DD
DateFormat(text){
if(text.length==8){
var reg = /(\d{4})(\d{2})(\d{2})/;
text = text.replace(reg, '$1-$2-$3');
return text;
}
return text;
},
如需格式化为:YYYY-MM-DD HH:mm:ss
DateFormat(text){
if(text.length==14){
var reg = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;
text = text.replace(reg, '$1-$2-$3 $4:$5:$6');
return text;
}
return text;
},
博客提及了可将时间格式化为 YYYY - MM - DD,若需格式化为 YYYY - MM - DD HH:mm:ss 也有对应方法,涉及前端开发中时间格式化相关内容。
1798

被折叠的 条评论
为什么被折叠?



