frontend/containers/DrawerNotification/formatDate.ts (view raw)
1import moment from 'moment';
2import {useTranslation} from 'next-i18next';
3
4export const formatDate = (dateString: string) => {
5 const momentDate = moment(dateString);
6 const isToday = momentDate.isSame(moment(), 'day');
7 const {t} = useTranslation();
8
9 if (isToday) {
10 return `${t('date.today')}, ${momentDate.format('hh:mm')}`;
11 } else {
12 return momentDate.format('DD/MM/YY, H:mm');
13 }
14};