CEES-manage/src/utils/dateUtil.ts

18 lines
523 B
TypeScript
Raw Normal View History

2021-10-20 14:32:09 +08:00
/**
* Independent time operation tool to facilitate subsequent switch to dayjs
*/
import dayjs from 'dayjs';
2021-10-20 14:32:09 +08:00
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
const DATE_FORMAT = 'YYYY-MM-DD';
2021-10-20 14:32:09 +08:00
export function formatToDateTime(date: dayjs.Dayjs | undefined = undefined, format = DATE_TIME_FORMAT): string {
return dayjs(date).format(format);
2021-10-20 14:32:09 +08:00
}
export function formatToDate(date: dayjs.Dayjs | undefined = undefined, format = DATE_FORMAT): string {
return dayjs(date).format(format);
2021-10-20 14:32:09 +08:00
}
export const dateUtil = dayjs;