Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

use-timestamp.ts 538B

123456789101112131415161718192021
  1. 'use client'
  2. import { useCallback } from 'react'
  3. import dayjs from 'dayjs'
  4. import utc from 'dayjs/plugin/utc'
  5. import timezone from 'dayjs/plugin/timezone'
  6. import { useAppContext } from '@/context/app-context'
  7. dayjs.extend(utc)
  8. dayjs.extend(timezone)
  9. const useTimestamp = () => {
  10. const { userProfile: { timezone } } = useAppContext()
  11. const formatTime = useCallback((value: number, format: string) => {
  12. return dayjs.unix(value).tz(timezone).format(format)
  13. }, [timezone])
  14. return { formatTime }
  15. }
  16. export default useTimestamp