useConvertDateToTimezone
Hook that lets you convert a given date object that might be in a different timezone than the one selected in MoBro to the same timezone.
Returns
A callback that can take a Date
object which gets converted to the same timezone as the system MoBro is running on.
Example
src/widgets/example/Example.tsx
import React, {useEffect} from 'react'
import {useConvertDateToTimezone} from '@modbros/dashboard-sdk'
export default function Example() {
const convertDate = useConvertDateToTimezone()
const [convertedDate, setConvertedDate] = useState<Date | null>(null)
useEffect(() => {
fetch('https://a-time-in-a-different-timezone')
.then((dateTimeString: string) => {
const date = new Date(dateTimeString)
setConvertedDate(convertDate(date))
})
}, [])
return null
}