dateUtil.ts 428 字节
Newer Older
陈文彬 已提交
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);
陈文彬 已提交
11 12
}

13 14
export function formatToDate(date: moment.MomentInput = null, format = DATE_FORMAT): string {
  return moment(date).format(format);
陈文彬 已提交
15 16 17
}

export const dateUtil = moment;