通过后台的毫秒,运用计算,转变成时间

Posted qiuligao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过后台的毫秒,运用计算,转变成时间相关的知识,希望对你有一定的参考价值。

1.计算属性

fmtDate () {
      return function (date) {
        let dateFn = new Date(date)
        let yy = dateFn.getFullYear()
        let mm = dateFn.getMonth() + 1
        let dd = dateFn.getDay()
        let hh = dateFn.getHours() < 10 ? ‘0‘ + dateFn.getHours() : ‘‘ + dateFn.getHours()
        let xx = dateFn.getMinutes() < 10 ? ‘0‘ + dateFn.getMinutes() : ‘‘ + dateFn.getMinutes()
        let ss = dateFn.getSeconds() < 10 ? ‘0‘ + dateFn.getSeconds() : ‘‘ + dateFn.getSeconds()
        let time = yy + ‘-‘ + mm + ‘-‘ + dd + ‘    ‘ + hh + ‘:‘ + xx + ‘:‘ + ss
        return time
      }
    }

2.html中运用

<p class="down-date">{{fmtDate(item.createDate)}}</p>

createDate: 后台的时间接口

以上是关于通过后台的毫秒,运用计算,转变成时间的主要内容,如果未能解决你的问题,请参考以下文章

JavaSE案例 02——Date日期类时间格式化类的综合运用案例

Sleep() 方法后的代码片段没有被执行

JS计算时间差

了解编译原理

java中怎么计算一个方法执行时,耗费多少毫秒

python数字怎么转变时间?