format date

This commit is contained in:
felixu
2018-10-08 16:35:51 +08:00
parent 1b4f75b064
commit e210939882
3 changed files with 33 additions and 3 deletions
@@ -39,7 +39,12 @@ function getcolumns() {
},
{
field: 'deploymentTime',
title: '部署时间'
title: '部署时间',
align: 'center',
formatter: function (value, row, index) {
var date = row.deploymentTime;
return formatDate(new Date(date));
}
},
{
title: '操作',
@@ -90,11 +90,21 @@
},
{
field: 'createTime',
title: '创建时间'
title: '创建时间',
align: 'center',
formatter: function (value, row, index) {
var date = row.createTime;
return formatDate(new Date(date));
}
},
{
field: 'lastUpdateTime',
title: '最后更新时间'
title: '最后更新时间',
align: 'center',
formatter: function (value, row, index) {
var date = row.lastUpdateTime;
return formatDate(new Date(date));
}
},
{
title: '操作',
@@ -257,4 +257,19 @@ function dt_action(title, action) {
area: ['800px', '520px'],
content: url + action // iframe的url
});
}
/**
* 格式化日期
* @param now
* @returns {string}
*/
function formatDate(now) {
var year = now.getFullYear();
var month = now.getMonth()+1;
var date = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds() > 10 ? now.getSeconds() : '0' + now.getSeconds();
return year + "-" + month + "-" + date+ " " + hour + ":" + minute + ":" + second;
}