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/useFormatDateAndTime.js

21 lines
611 B

import { useCallback } from 'react';
import moment from 'moment';
import { useUserPreference } from '../contexts/UserContext';
import { useSetting } from '../contexts/SettingsContext';
export const useFormatDateAndTime = () => {
const clockMode = useUserPreference('clockMode', false);
const format = useSetting('Message_TimeAndDateFormat');
return useCallback((time) => {
switch (clockMode) {
case 1:
return moment(time).format('MMMM D, Y h:mm A');
case 2:
return moment(time).format('MMMM D, Y H:mm');
default:
return moment(time).format(format);
}
}, [clockMode, format]);
};