From e72830349697e04e549c3bd5f4b2da7461479eec Mon Sep 17 00:00:00 2001 From: KMKoushik Date: Sat, 2 Nov 2024 06:52:12 +1100 Subject: [PATCH] fix date format error --- src/pages/groups/[groupId].tsx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/pages/groups/[groupId].tsx b/src/pages/groups/[groupId].tsx index 6d67913..8e2e8e4 100644 --- a/src/pages/groups/[groupId].tsx +++ b/src/pages/groups/[groupId].tsx @@ -121,6 +121,8 @@ const BalancePage: NextPageWithUser<{ ); } + console.log('expensesQuery.data', expensesQuery.data); + return ( <> @@ -167,12 +169,12 @@ const BalancePage: NextPageWithUser<{

First expense

- {format( - new Date( - expensesQuery.data[expensesQuery.data.length - 1]?.createdAt ?? '', - ).toLocaleDateString(), - 'yyyy-MM-dd', - )} + {expensesQuery.data[expensesQuery.data.length - 1]?.createdAt + ? format( + expensesQuery.data[expensesQuery.data.length - 1]!.createdAt, + 'MMM dd, yyyy', + ) + : '--'}

)} @@ -200,12 +202,7 @@ const BalancePage: NextPageWithUser<{ {groupDetailQuery?.data?.createdAt && (

Group created

-

- {format( - new Date(groupDetailQuery.data?.createdAt).toLocaleDateString(), - 'yyyy-MM-dd', - )} -

+

{format(groupDetailQuery.data?.createdAt, 'MMM dd, yyyy')}

)}