Showing
2 changed files
with
20 additions
and
3 deletions
1 | let Vue = require('yoho-vue'); | 1 | let Vue = require('yoho-vue'); |
2 | -const moment = require('moment'); | ||
3 | 2 | ||
4 | /** | 3 | /** |
5 | * 替换参数 | 4 | * 替换参数 |
@@ -118,6 +117,23 @@ Vue.filter('convertTime', (value) => { | @@ -118,6 +117,23 @@ Vue.filter('convertTime', (value) => { | ||
118 | /** | 117 | /** |
119 | * 格式化时间 | 118 | * 格式化时间 |
120 | */ | 119 | */ |
121 | -Vue.filter('formatUnixTime', (value, format) => { | ||
122 | - return moment.unix(value).format(format || 'YYYY-MM-DD HH:mm:ss'); | 120 | +Vue.filter('formatUnixTime', (value) => { |
121 | + // return moment.unix(value).format(format || 'YYYY-MM-DD HH:mm:ss'); | ||
122 | + | ||
123 | + if (typeof value === 'undefined') { | ||
124 | + return; | ||
125 | + } | ||
126 | + | ||
127 | + let date = new Date(parseFloat(value) * 1000); | ||
128 | + | ||
129 | + // let Y = date.getFullYear() + '-'; | ||
130 | + let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1); | ||
131 | + let D = (date.getDate() + 1 < 10 ? '0' + (date.getDate() + 1) : date.getDate() + 1); | ||
132 | + let h = date.getHours(); | ||
133 | + let m = date.getMinutes(); | ||
134 | + | ||
135 | + // let s = date.getSeconds(); | ||
136 | + | ||
137 | + // return M + '.' + D + ' ' + h + ' ' + ' ' + m + ' ' + s; | ||
138 | + return `${M}.${D} ${h}:${m}`; | ||
123 | }); | 139 | }); |
-
Please register or login to post a comment