Blame view

src/utils/dateUtil.ts 428 Bytes
陈文彬 authored
1
2
3
4
5
import moment from 'moment';

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

export const dateUtil = moment;