vue-vben-admin/src/utils/dateUtil.ts

21 lines
512 B
TypeScript
Raw Normal View History

/**
* 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 ';
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
}
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;