2021-03-12 21:40:23 +08:00
|
|
|
/**
|
|
|
|
|
* Independent time operation tool to facilitate subsequent switch to dayjs
|
|
|
|
|
*/
|
2020-09-28 20:19:10 +08:00
|
|
|
import moment from 'moment';
|
|
|
|
|
|
|
|
|
|
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
|
|
|
|
|
const DATE_FORMAT = 'YYYY-MM-DD ';
|
|
|
|
|
|
2020-12-31 21:24:47 +08:00
|
|
|
export function formatToDateTime(
|
2021-07-23 07:29:39 +08:00
|
|
|
date: moment.MomentInput = undefined,
|
2021-08-24 22:41:48 +08:00
|
|
|
format = DATE_TIME_FORMAT,
|
2020-12-31 21:24:47 +08:00
|
|
|
): string {
|
|
|
|
|
return moment(date).format(format);
|
2020-09-28 20:19:10 +08:00
|
|
|
}
|
|
|
|
|
|
2021-07-23 07:29:39 +08:00
|
|
|
export function formatToDate(date: moment.MomentInput = undefined, format = DATE_FORMAT): string {
|
2020-12-31 21:24:47 +08:00
|
|
|
return moment(date).format(format);
|
2020-09-28 20:19:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const dateUtil = moment;
|