mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
22 lines
538 B
TypeScript
22 lines
538 B
TypeScript
|
'use client'
|
||
|
import { useCallback } from 'react'
|
||
|
import dayjs from 'dayjs'
|
||
|
import utc from 'dayjs/plugin/utc'
|
||
|
import timezone from 'dayjs/plugin/timezone'
|
||
|
import { useAppContext } from '@/context/app-context'
|
||
|
|
||
|
dayjs.extend(utc)
|
||
|
dayjs.extend(timezone)
|
||
|
|
||
|
const useTimestamp = () => {
|
||
|
const { userProfile: { timezone } } = useAppContext()
|
||
|
|
||
|
const formatTime = useCallback((value: number, format: string) => {
|
||
|
return dayjs.unix(value).tz(timezone).format(format)
|
||
|
}, [timezone])
|
||
|
|
||
|
return { formatTime }
|
||
|
}
|
||
|
|
||
|
export default useTimestamp
|