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)