mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-21 06:34:30 +01:00
added timezone settings
This commit is contained in:
26
components/DynamicTime.tsx
Normal file
26
components/DynamicTime.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import moment from 'moment-timezone'
|
||||
|
||||
interface DynamicTimeProps {
|
||||
timezone: string
|
||||
}
|
||||
|
||||
export function DynamicTime({ timezone }: DynamicTimeProps) {
|
||||
const [time, setTime] = useState(moment())
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setTime(moment())
|
||||
}, 1000)
|
||||
|
||||
return () => clearInterval(timer)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="text-sm text-muted-foreground">
|
||||
{time.tz(timezone).format('dddd, MMMM D, YYYY h:mm:ss A')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user