問題:
列表中展示的日期字段: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 "";
}