Skip to content

Commit 29352bf

Browse files
committed
feat(@142vip/utils): 增加formatDateToYMD日期封装
1 parent 49e7028 commit 29352bf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/utils/src/pkgs/dayjs.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@ function formatDateToStr(date: Date, template?: string) {
1818
return dayjs(date).format(template ?? FormatTemplateStr)
1919
}
2020

21+
/**
22+
* 年月日格式化当前时间
23+
* - 格式: 2024-08-09
24+
*/
25+
function formatDateToYMD(): string {
26+
return formatDateToStr(new Date(), 'YYYY-MM-DD')
27+
}
28+
2129
export interface IVipDayjs {
2230
getCurrentTimestamp: typeof getCurrentTimestamp
2331
FormatTemplateStr: typeof FormatTemplateStr
2432
formatDateToStr: typeof formatDateToStr
33+
formatDateToYMD: typeof formatDateToYMD
2534
}
2635

2736
export const VipDayjs: IVipDayjs = {
2837
getCurrentTimestamp,
2938
FormatTemplateStr,
3039
formatDateToStr,
40+
formatDateToYMD,
3141
}

0 commit comments

Comments
 (0)