Blame view

src/utils/dateUtil.ts 525 Bytes
1
2
3
/**
 * Independent time operation tool to facilitate subsequent switch to dayjs
 */
陈文彬 authored
4
5
import moment from 'moment';
6
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
vben authored
7
const DATE_FORMAT = 'YYYY-MM-DD';
陈文彬 authored
8
9
export function formatToDateTime(
10
  date: moment.MomentInput = undefined,
vben authored
11
  format = DATE_TIME_FORMAT,
12
13
): string {
  return moment(date).format(format);
陈文彬 authored
14
15
}
16
export function formatToDate(date: moment.MomentInput = undefined, format = DATE_FORMAT): string {
17
  return moment(date).format(format);
陈文彬 authored
18
19
20
}

export const dateUtil = moment;