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(
|
|
|
|
|
date: moment.MomentInput = null,
|
|
|
|
|
format = DATE_TIME_FORMAT
|
|
|
|
|
): string {
|
|
|
|
|
return moment(date).format(format);
|
2020-09-28 20:19:10 +08:00
|
|
|
}
|
|
|
|
|
|
2020-12-31 21:24:47 +08:00
|
|
|
export function formatToDate(date: moment.MomentInput = null, format = DATE_FORMAT): string {
|
|
|
|
|
return moment(date).format(format);
|
2020-09-28 20:19:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const dateUtil = moment;
|