格式化时间 将2021-09-05T09:08:03.000Z 转换成 YYYY-MM-DD HH:mm:ss 格式

格式化时间

将2021-09-05T09:08:03.000Z 转换成 YYYY-MM-DD HH:mm:ss 格式

1.引入第三方包 dayjs (一个轻量的处理时间和日期的javascript库)
(1)下载 npm install/ i dayjs --save
(2). main.js 中全局引入

    `import dayjs from 'dayjs
    Vue.prototype.dayjs=dayjs'

2 时间转换函数

 timeTranslate (val) {
     
      return this.dayjs(val).format('YYYY-MM-DD HH:mm:ss')
    },

3 调用函数

          <el-table-column align="center" label="录入时间">
            <template slot-scope="scope">
              <span>{
     {
     timeTranslate(scope.row.addDate)}}</span>
            </template>
          </el-table-column>

你可能感兴趣的:(项目,格式化时间,javascript)