vue中el-table对时间的处理

 <el-table-column prop="dateTime"
       label="上课时间"
       min-width="150"
      :formatter="timestampToTime"
      show-overflow-tooltip></el-table-column>
methods:{
timestampToTime(row, column) {
      console.log(row.date)
      //20200904针对str类型的时间进行格式转换
      var date = row.date
      var year = date.substr(0, 4)
      var month = date.substr(4, 2)
      var day = date.substr(6, 2)
      var start = date.substr(9, 5)
      var end = date.substr(15, 5)
      var time = date.substr(9)
      return year + '年' + month + '月' + day + '日' + ' ' + start + '~' + end
      
      //针对时间挫进行格式转换
      // let date1 = date.split(' ')[0]
      // var Y = date1.getFullYear() + '-'
      // var M =
      //   (date.getMonth() + 1 < 10
      //     ? '0' + (date.getMonth() + 1)
      //     : date.getMonth() + 1) + '-'
      // var D = date.getDate() + ' '
      // var h = date.getHours() + ':'
      // var m = date.getMinutes() + ':'
      // var s = date.getSeconds()
      // return Y + M + D + h + m + s
    },
}
Logo

前往低代码交流专区

更多推荐