From af931b764c0582b3292db7a5cd446cdef58b63b9 Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 1 Oct 2024 13:46:53 +0200 Subject: [PATCH] fix(formatted date): show month and date with two digits --- app/hooks/useFormattedDate.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/hooks/useFormattedDate.ts b/app/hooks/useFormattedDate.ts index bfa7ef3..5930ef2 100644 --- a/app/hooks/useFormattedDate.ts +++ b/app/hooks/useFormattedDate.ts @@ -1,4 +1,6 @@ export function useFormattedDate(_date: string) { - const date = new Date(_date) - return `${date.getUTCFullYear()}/${date.getUTCMonth()}/${date.getUTCDate()}` + const date = new Date(_date); + const month = date.getUTCMonth().toString().padStart(2, "0"); + const monthDate = date.getUTCDate().toString().padStart(2, "0"); + return `${date.getUTCFullYear()}/${month}/${monthDate}`; }