Blame view

src/utils/dateUtil.ts 512 Bytes
1
2
3
/**
 * Independent time operation tool to facilitate subsequent switch to dayjs
 */
陈文彬 authored
4
5
6
7
8
import moment from 'moment';

const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
const DATE_FORMAT = 'YYYY-MM-DD ';
9
10
11
12
13
export function formatToDateTime(
  date: moment.MomentInput = null,
  format = DATE_TIME_FORMAT
): string {
  return moment(date).format(format);
陈文彬 authored
14
15
}
16
17
export function formatToDate(date: moment.MomentInput = null, format = DATE_FORMAT): string {
  return moment(date).format(format);
陈文彬 authored
18
19
20
}

export const dateUtil = moment;