Blame view

src/utils/dateUtil.ts 487 Bytes
1
2
3
/**
 * Independent time operation tool to facilitate subsequent switch to dayjs
 */
4
import dayjs from 'dayjs';
陈文彬 authored
5
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(date?: dayjs.ConfigType, format = DATE_TIME_FORMAT): string {
10
  return dayjs(date).format(format);
陈文彬 authored
11
12
}
13
export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): string {
14
  return dayjs(date).format(format);
陈文彬 authored
15
16
}
17
export const dateUtil = dayjs;