码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-12-17 14:31:24      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:html   day   col   new   code   转变   function   cond   通过   

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: 后台的时间接口

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

标签:html   day   col   new   code   转变   function   cond   通过   

原文地址:https://www.cnblogs.com/qiuligao/p/10130618.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!