提交 | 用户 | age
|
a89eee
|
1 |
/** |
V |
2 |
* Independent time operation tool to facilitate subsequent switch to dayjs |
|
3 |
*/ |
3fcfac
|
4 |
import dayjs from 'dayjs'; |
2f6253
|
5 |
|
522534
|
6 |
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'; |
090d84
|
7 |
const DATE_FORMAT = 'YYYY-MM-DD'; |
74a35f
|
8 |
const DATE_DAY_FORMAT = 'YYYY-MM-DD HH:mm'; |
H |
9 |
|
2f6253
|
10 |
|
553919
|
11 |
export function formatToDateTime(date?: dayjs.ConfigType, format = DATE_TIME_FORMAT): string { |
3fcfac
|
12 |
return dayjs(date).format(format); |
2f6253
|
13 |
} |
陈 |
14 |
|
384f92
|
15 |
export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): string { |
3fcfac
|
16 |
return dayjs(date).format(format); |
2f6253
|
17 |
} |
74a35f
|
18 |
export function formatToDateDay(date?: dayjs.ConfigType, format = DATE_DAY_FORMAT): string { |
H |
19 |
return dayjs(date).format(format); |
|
20 |
} |
|
21 |
export function isBeforeToDay(date?: dayjs.ConfigType): boolean { |
|
22 |
//获取今天的日期 |
|
23 |
const now = dayjs(); |
|
24 |
return dayjs(date).isBefore(dayjs(now)); |
|
25 |
} |
2f6253
|
26 |
|
3fcfac
|
27 |
export const dateUtil = dayjs; |