!510 【修复】修复时间格式错误

Merge pull request !510 from 半栈幼儿员/hotfix/date-format
pull/509/MERGE
芋道源码 2024-08-23 11:25:53 +00:00 committed by Gitee
commit c820b5a574
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 8 additions and 8 deletions

View File

@ -56,20 +56,20 @@ export const defaultShortcuts = [
*
* @param date new Date()
* @param format
* @description format `YYYY-mm、YYYY-mm-dd`
* @description format "YYYY-mm-dd HH:MM:SS QQQQ"
* @description format "YYYY-mm-dd HH:MM:SS WWW"
* @description format "YYYY-mm-dd HH:MM:SS ZZZ"
* @description format + + "YYYY-mm-dd HH:MM:SS WWW QQQQ ZZZ"
* @description format `YYYY-MM、YYYY-MM-DD`
* @description format "YYYY-MM-DD HH:mm:ss QQQQ"
* @description format "YYYY-MM-DD HH:mm:ss WWW"
* @description format "YYYY-MM-DD HH:mm:ss ZZZ"
* @description format + + "YYYY-MM-DD HH:mm:ss WWW QQQQ ZZZ"
* @returns
*/
export function formatDate(date: Date, format?: string): string {
// 日期不存在,则返回空
if (!date) {
return '';
return ''
}
// 日期存在,则进行格式化
return date ? dayjs(date).format(format ?? 'YYYY-MM-DD HH:mm:ss') : '';
return date ? dayjs(date).format(format ?? 'YYYY-MM-DD HH:mm:ss') : ''
}
/**
@ -110,7 +110,7 @@ export function getWeek(dateTime: Date): number {
* @description param 3 60 * 60* 24 * 1000 * 3
* @returns
*/
export function formatPast(param: string | Date, format = 'YYYY-mm-dd HH:MM:SS'): string {
export function formatPast(param: string | Date, format = 'YYYY-MM-DD HH:mm:ss'): string {
// 传入格式处理、存储转换值
let t: any, s: number
// 获取js 时间戳