diff --git a/src/utils/tools.js b/src/utils/tools.js index 82c9c542..cef104af 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -148,6 +148,29 @@ export function formatDate(date){ return newTime; } + +/** + * 把日期格式化为显示时间,yyyy-MM-dd + * @param {Object} date + */ +export function formatDateShort(date){ + var year = date.getFullYear(), + month = date.getMonth() + 1,//月份是从0开始的 + day = date.getDate(), + hour = date.getHours(), + min = date.getMinutes(), + sec = date.getSeconds(); + if(month<10){month='0'+month} + if(day<10){day='0'+day} + if(hour<10){hour='0'+hour} + if(min<10){min='0'+min} + if(sec<10){sec='0'+sec} + var newTime = year + '-' + month + '-' + day; + return newTime; + +} + + export function numberToLetter(x){ //此方法和移到utils中去 let s = ""; while (x > 0) {