From f7956a9716d164a09378da6bc6c9506e27f50842 Mon Sep 17 00:00:00 2001 From: weinan2087 Date: Fri, 21 Oct 2022 14:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=87=BD=E6=95=B0=EF=BC=9Afo?= =?UTF-8?q?rmatDateShort?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/tools.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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) {