init
This commit is contained in:
12
worklenz-frontend/src/utils/format-date-time-with-locale.ts
Normal file
12
worklenz-frontend/src/utils/format-date-time-with-locale.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { format } from 'date-fns';
|
||||
import { enUS, es, pt } from 'date-fns/locale';
|
||||
import { getLanguageFromLocalStorage } from './language-utils';
|
||||
|
||||
export const formatDateTimeWithLocale = (dateString: string): string => {
|
||||
if (!dateString) return '';
|
||||
|
||||
const date = new Date(dateString);
|
||||
const localeString = getLanguageFromLocalStorage();
|
||||
const locale = localeString === 'en' ? enUS : localeString === 'es' ? es : pt;
|
||||
return format(date, 'MMM d, yyyy, h:mm:ss a', { locale });
|
||||
};
|
||||
Reference in New Issue
Block a user