邓洁: 修改细节

This commit is contained in:
邓洁
2024-01-08 09:31:34 +08:00
parent 1ab43e97e3
commit 060ff853d4
7 changed files with 38 additions and 25 deletions

View File

@@ -1,9 +1,10 @@
export const dateFormat = (time = new Date().getTime()) => { //YYYY年MM月DD日 星期d
export const dateFormat = (time = new Date().getTime(),flag) => { //YYYY年MM月DD日 星期d
const _time = time.toString().length > 10 ? time : time * 1000
const weekList = ["日","一", "二", "三", "四", "五", "六" ];
const date = new Date(_time);
const Y = date.getFullYear();
const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
const Mm = (date.getMonth() + 1 < 10 ? (date.getMonth() + 1) : date.getMonth() + 1);
const D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
const h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
const m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
@@ -11,7 +12,11 @@ export const dateFormat = (time = new Date().getTime()) => { //YYYY年MM月DD日
let weekDay = new Date().getDay();
const week= weekList[weekDay]
// const strDate = `${Y}/${M}/${D} ${h}:${m}:${s}`
return `${Y}${M}${D}日 星期${week}`;
if(flag){
return `${Mm}`;
}else {
return `${Y}${M}${D}日 星期${week}`;
}
}
export default {