This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import dateFunc, { type ConfigType } from 'dayjs';
const DATE_TIME_TEMPLATE = 'YYYY-MM-DD HH:mm:ss';
const DATE_TEMPLATE = 'YYYY-MM-DD';
/**
* @zh_CN 格式化日期时间
* @param date 待格式化的日期时间
* @param format 格式化的方式
* @returns 格式化后的日期字符串,默认:YYYY-MM-DD HH:mm:ss
*/
function formatDate(date?: ConfigType, format = DATE_TEMPLATE): string {
return dateFunc(date).format(format);
}
* @returns 格式化后的日期字符串
function formatDateTime(date?: ConfigType): string {
return formatDate(date, DATE_TIME_TEMPLATE);
export { formatDate, formatDateTime };