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