UNPKG

ci-plus

Version:

ci组件库

24 lines (22 loc) 700 B
/** * * 这是用来格式化日期的函数 * ! 一共有两个函数 * ? 第一个函数是输出日期型 * TODO: 第二个函数输出日期时间型 * @param date 传入日期或者字符串 * @param geshi? 想要输出的格式 */ import dayjs from 'dayjs' // 格式化日期 export const setDate = (date?: string | Date, geshi: string = 'YYYY-MM-DD') => { if (date == '' || date == null || date == undefined) { return '' } else { return dayjs(date).format(geshi) } } // 格式化日期时间 export const setDateTime = (date: string | Date, geshi: string = 'YYYY-MM-DD hh:mm:ss'): string => { return dayjs(date).format(geshi) } export { dayjs }