mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-04-20 12:49:43 +08:00
13 lines
369 B
TypeScript
13 lines
369 B
TypeScript
import dayjs from 'dayjs'
|
|
import { useCallback } from 'react'
|
|
import { useI18N } from '@/context/i18n'
|
|
|
|
export const useFormatTimeFromNow = () => {
|
|
const { locale } = useI18N()
|
|
const formatTimeFromNow = useCallback((time: number) => {
|
|
return dayjs(time).locale(locale === 'zh-Hans' ? 'zh-cn' : locale).fromNow()
|
|
}, [locale])
|
|
|
|
return { formatTimeFromNow }
|
|
}
|