Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
14 replies
pradeep800

dates are not same in server and client(dayjs)

 currentDate = new Date();
  const options = { timeZone: "Asia/Kolkata" };
  const indianDateAndTime = currentDate.toLocaleString("en-US", options);
  const indianDate = indianDateAndTime.substring(0, 9) as string;
  const date = dayjs.tz(indianDate, "Asia/Kolkata");
  const minDate = date.add(minReminderRange, "day").toDate();

  const maxDate = date.add(maxReminderRange, "day").toDate();
  console.log(maxDate.toISOString(), minDate.toISOString());  

this is giving output in client as
2023-08-07T13:00:00.000Z 2023-07-12T13:00:00.000Z
output in server
2023-08-07T18:30:00.000Z 2023-07-12T18:30:00.000Z
can anyone tell me why it is happening
Was this page helpful?