2021-03-12 21:40:23 +08:00
|
|
|
/**
|
|
|
|
|
* Independent time operation tool to facilitate subsequent switch to dayjs
|
|
|
|
|
*/
|
2021-11-10 22:12:10 +08:00
|
|
|
import dayjs from 'dayjs';
|
2020-09-28 20:19:10 +08:00
|
|
|
|
2021-10-29 20:09:43 +08:00
|
|
|
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
2021-11-11 22:28:39 +08:00
|
|
|
const DATE_FORMAT = 'YYYY-MM-DD';
|
2020-09-28 20:19:10 +08:00
|
|
|
|
2022-11-11 09:52:30 +08:00
|
|
|
export function formatToDateTime(date?: dayjs.ConfigType, format = DATE_TIME_FORMAT): string {
|
2021-11-10 22:12:10 +08:00
|
|
|
return dayjs(date).format(format);
|
2020-09-28 20:19:10 +08:00
|
|
|
}
|
|
|
|
|
|
2022-11-10 11:58:33 +08:00
|
|
|
export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): string {
|
2021-11-10 22:12:10 +08:00
|
|
|
return dayjs(date).format(format);
|
2020-09-28 20:19:10 +08:00
|
|
|
}
|
|
|
|
|
|
2021-11-10 22:12:10 +08:00
|
|
|
export const dateUtil = dayjs;
|