mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 13:17:19 +01:00
Created formatDate function for rendering dates in correct timezone.
This commit is contained in:
parent
b11b2e3524
commit
9b005e11c0
3 changed files with 12 additions and 19 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { setItem } from 'next-basics';
|
||||
import { TIMEZONE_CONFIG } from 'lib/constants';
|
||||
import { formatInTimeZone } from 'date-fns-tz';
|
||||
import useStore, { setTimezone } from 'store/app';
|
||||
|
||||
const selector = (state: { timezone: string }) => state.timezone;
|
||||
|
|
@ -12,7 +13,11 @@ export function useTimezone() {
|
|||
setTimezone(value);
|
||||
};
|
||||
|
||||
return { timezone, saveTimezone };
|
||||
const formatDate = (date: string, pattern: string) => {
|
||||
return formatInTimeZone(date.split(' ').join('T') + 'Z', timezone, pattern);
|
||||
};
|
||||
|
||||
return { timezone, saveTimezone, formatDate };
|
||||
}
|
||||
|
||||
export default useTimezone;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue