|
|
@@ -1,6 +1,12 @@
|
|
|
import dayjs from 'dayjs'
|
|
|
import 'dayjs/locale/zh-cn'
|
|
|
+import relativeTime from 'dayjs/plugin/relativeTime' // 使用dayjs自带插件
|
|
|
|
|
|
dayjs.locale('zh-cn')
|
|
|
+dayjs.extend(relativeTime) // 导入相对时间插件
|
|
|
+
|
|
|
+export const timestampFormat = (time: number, type?: string) => dayjs(time).format(type || 'YYYY-MM-DD') // YYYY-MM-DD HH:mm:ss
|
|
|
+export const formatTime = (time: any) => dayjs(time).fromNow()
|
|
|
+
|
|
|
|
|
|
export default dayjs
|