vue 时间处理filter

{{getDetailData.updated_time | formatDate}}

 

        filters: {
            formatDate (time) {
                if(time) {
                    let timestamp = (new Date()).valueOf()
                    let stamp = parseInt(Math.abs(timestamp - time) / 1000 / 60 / 60 /24)
                    if(stamp) {
                        if(stamp <= 14) {
                            return `${stamp}天前`
                        } else {
                            return `最近`
                        }
                    } else {
                        stamp = parseInt(Math.abs(timestamp - time) / 1000 / 60 / 60)
                        if(stamp) {
                            return `${stamp}小时前`
                        } else {
                            stamp = parseInt(Math.abs(timestamp - time) / 1000 / 60)
                            if(stamp) {
                   

你可能感兴趣的:(日期对象)