vue+element ui 时间格式化
<el-table-column prop="startTime" label="日期" width="200" align="center" :formatter="formatStartTime" /> formatStartTime(row, column) { const value = row.createTime var year = value.substr(0, 4) var month = value.substr(4, 2) var day = value.substr(6, 2) var hour = value.substr(8, 2) var minute = value.substr(10, 2) var second = value.substr(12, 2) return year + '-' + month + '-' + day + ' ' + ' ' + hour + ':' + minute + ':' + second },
<el-table-column property="createDate" label="时间" :formatter="dateFormat" />
dateFormat(row, column, cellValue, index) {
var date = cellValue
if (!date) {
return ''
}
return moment(date).format('YYYY-MM-DD')
},