The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rocket.Chat/client/hooks/useTimezoneTime.js

20 lines
532 B

import { useState, useEffect } from 'react';
import moment from 'moment';
import { useFormatTime } from './useFormatTime';
export const useTimezoneTime = (offset, interval = 1000) => {
const [time, setTime] = useState(null);
const format = useFormatTime();
useEffect(() => {
if (offset === undefined) {
return;
}
const update = () => setTime(moment().utcOffset(offset));
const timer = setInterval(update, interval);
update();
return () => clearInterval(timer);
}, [offset, interval]);
return format(time);
};