From e47242a0ab3ce7f2a3251a8738eeabd71c7f3923 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 09 十一月 2023 16:43:45 +0800
Subject: [PATCH] a
---
admin/src/utils/util.js | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/admin/src/utils/util.js b/admin/src/utils/util.js
index c52e471..d1b2aff 100644
--- a/admin/src/utils/util.js
+++ b/admin/src/utils/util.js
@@ -37,3 +37,31 @@
return 3
}
}
+
+//涓嬮潰鏄竴涓�氱敤杈冮珮鐨勮嚜瀹氫箟鏃ユ湡鏃堕棿鏍煎紡鍖栧嚱鏁扮殑绀轰緥锛�
+export function formatDateTime(date, format) {
+ const o = {
+ 'M+': date.getMonth() + 1, // 鏈堜唤
+ 'd+': date.getDate(), // 鏃�
+ 'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12, // 灏忔椂
+ 'H+': date.getHours(), // 灏忔椂
+ 'm+': date.getMinutes(), // 鍒�
+ 's+': date.getSeconds(), // 绉�
+ 'q+': Math.floor((date.getMonth() + 3) / 3), // 瀛e害
+ S: date.getMilliseconds(), // 姣
+ a: date.getHours() < 12 ? '涓婂崍' : '涓嬪崍', // 涓婂崍/涓嬪崍
+ A: date.getHours() < 12 ? 'AM' : 'PM', // AM/PM
+ };
+ if (/(y+)/.test(format)) {
+ format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
+ }
+ for (let k in o) {
+ if (new RegExp('(' + k + ')').test(format)) {
+ format = format.replace(
+ RegExp.$1,
+ RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
+ );
+ }
+ }
+ return format;
+}
--
Gitblit v1.9.3