bootstrap 列表 bootstrap-table 日期格式轉換


問題:

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM