普兆健康管家后端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
523 B

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