dateUtil.ts 526 字节
Newer Older
1 2 3
/**
 * Independent time operation tool to facilitate subsequent switch to dayjs
 */
陈文彬 已提交
4 5
import moment from 'moment';

6
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
陈文彬 已提交
7 8
const DATE_FORMAT = 'YYYY-MM-DD ';

9
export function formatToDateTime(
10
  date: moment.MomentInput = undefined,
V
vben 已提交
11
  format = DATE_TIME_FORMAT,
12 13
): string {
  return moment(date).format(format);
陈文彬 已提交
14 15
}

16
export function formatToDate(date: moment.MomentInput = undefined, format = DATE_FORMAT): string {
17
  return moment(date).format(format);
陈文彬 已提交
18 19 20
}

export const dateUtil = moment;