Vue第三篇之vue.js時間戳轉時間字串
阿新 • • 發佈:2019-01-05
直接上乾貨:
formartDate(param) { let date = new Date(param); Y = date.getFullYear() + '-'; M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-'; D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' '; h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':'; m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':'; s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds(); return Y + M + D + h + m + s; }