0

I am trying to find the start date and end date of relative times in different timezones since client and server are in two different timezones.

If they are in the same timezone. I would be able to find the start date and end date as following:

const startDate = new Date();
startDate.setUTCHours(0,0,0,0);

const endDate = new Date();
endDate.setUTCHours(23,59,59,999);

How could we get the start date and end date for the backend time zone given that we know the time zone or time zone offset for both frontend and backend? For example:

  • Current front end time: May 3, 2022, 6:00 PM PDT (GMT-7)
  • Current backend time: May 4, 2022, 9:00 AM SST (GMT+8)

The goal is to get start time and end time for within today as following:

  • start time: May 4, 2022, 00:00 AM SST (GMT+8)
  • end time: May 4, 2022, 12:00 PM SST (GMT+8)
Donut
  • 31
  • 1
  • 6
  • There is an answer [*here*](https://stackoverflow.com/a/62184109/257182) that, given a Date object and IANA location, returns the start of day for a particular IANA location. To get end of day, get start of day for the following day. Then test if the date is between the start and end at the desired location. – RobG May 04 '22 at 04:01

0 Answers0