diff --git a/apps/Frontend/src/components/appointments/appointment-form.tsx b/apps/Frontend/src/components/appointments/appointment-form.tsx index c2ffbf8..a504c8e 100644 --- a/apps/Frontend/src/components/appointments/appointment-form.tsx +++ b/apps/Frontend/src/components/appointments/appointment-form.tsx @@ -258,11 +258,6 @@ export function AppointmentForm({ } const formattedDate = format(data.date, "yyyy-MM-dd"); - console.log( - "Updating with date:", - data.date, - format(data.date, "yyyy-MM-dd") - ); onSubmit({ ...data, diff --git a/apps/Frontend/src/pages/appointments-page.tsx b/apps/Frontend/src/pages/appointments-page.tsx index f476c3d..7e435c8 100644 --- a/apps/Frontend/src/pages/appointments-page.tsx +++ b/apps/Frontend/src/pages/appointments-page.tsx @@ -371,15 +371,20 @@ export default function AppointmentsPage() { const handleAppointmentSubmit = ( appointmentData: InsertAppointment | UpdateAppointment ) => { + // Converts local date to exact UTC date with no offset issues + function getUTCDateOnly(date: Date) { + return new Date( + Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) + ); + } + const rawDate = + appointmentData.date instanceof Date + ? appointmentData.date + : new Date(appointmentData.date); const updatedData = { ...appointmentData, - date: format( - appointmentData.date instanceof Date - ? appointmentData.date - : new Date(appointmentData.date), - "yyyy-MM-dd" - ), + date: getUTCDateOnly(rawDate), // 👈 This ensures consistent date across all environments }; // Check if we're editing an existing appointment with a valid ID