From d90aa5bd2b145351d2f3fa5981e62fbffaadf623 Mon Sep 17 00:00:00 2001 From: Potenz Date: Tue, 15 Jul 2025 23:28:01 +0530 Subject: [PATCH] date issue fixed4 --- apps/Frontend/src/utils/dateUtils.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/Frontend/src/utils/dateUtils.ts b/apps/Frontend/src/utils/dateUtils.ts index 40b3a06..fc82c61 100644 --- a/apps/Frontend/src/utils/dateUtils.ts +++ b/apps/Frontend/src/utils/dateUtils.ts @@ -52,10 +52,19 @@ export function toUTCDate(date: Date): Date { * and formats it as local yyyy-MM-dd string for UI use. */ export function formatUTCDateStringToLocal(dateStr: string): string { - const date = new Date(dateStr); // parsed as UTC - return formatLocalDate(date); + const date = new Date(dateStr); // still UTC + + // Create a local Date object with same year, month, day from UTC + const localDate = new Date( + date.getUTCFullYear(), + date.getUTCMonth(), + date.getUTCDate() + ); + + return formatLocalDate(localDate); // now safely in local time } + /** * Ensure any date (Date|string) is formatted to ISO string for consistent backend storage. * If it's already a string, pass through. If it's a Date, convert to ISO.