增加函数:formatDateShort

This commit is contained in:
weinan2087
2022-10-21 14:58:06 +08:00
parent 68fb4eaa91
commit f7956a9716

View File

@@ -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) {