dateUtil.ts 526 B

1234567891011121314151617181920
  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:ss';
  6. const DATE_FORMAT = 'YYYY-MM-DD ';
  7. export function formatToDateTime(
  8. date: moment.MomentInput = undefined,
  9. format = DATE_TIME_FORMAT,
  10. ): string {
  11. return moment(date).format(format);
  12. }
  13. export function formatToDate(date: moment.MomentInput = undefined, format = DATE_FORMAT): string {
  14. return moment(date).format(format);
  15. }
  16. export const dateUtil = moment;