lulaoshi

问题:

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

分类:

技术点:

相关文章:

  • 2021-05-27
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-10-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-21
  • 2021-12-13
  • 2021-10-07
  • 2022-12-23
  • 2022-01-04
  • 2021-12-03
相关资源
相似解决方案