dateUtil.ts 516 B

1234567891011121314151617
  1. /**
  2. * Independent time operation tool to facilitate subsequent switch to dayjs
  3. */
  4. import moment from 'moment';
  5. const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
  6. const DATE_FORMAT = 'YYYY-MM-DD ';
  7. export function formatToDateTime(date: moment.MomentInput = undefined, format = DATE_TIME_FORMAT): string {
  8. return moment(date).format(format);
  9. }
  10. export function formatToDate(date: moment.MomentInput = undefined, format = DATE_FORMAT): string {
  11. return moment(date).format(format);
  12. }
  13. export const dateUtil = moment;