问题:
列表中展示的日期字段:yyyy-MM-dd hh:ss:mm,要求展示展示的日期字段为:yyyy-MM-dd
处理方式:
//列表中添加格式转换
{title: '处理时间', field: 'replyTime', visible: true, align: 'center', valign: 'middle',
formatter: function (value, row, index) {
return changeDateFormat(value);
}
}
//创建函数
function changeDateFormat(cellval) {
if (cellval) {
var date = new Date(cellval);
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
return date.getFullYear() + "-" + month + "-" + currentDate;
}
return "";
}