Creating a Date
object with a dynamically selected timezone is my current goal while I am located in the IST time zone. To avoid the unpredictable behavior of Date.parse()
, I am looking for an alternative method. Let's say we set the tzOffset
to +05:30
as an example, but it can be changed depending on user preference. The issue arises when converting the date to UTC using
new Date(epochDate).toISOString();
. How can I achieve the desired format and specify the time zone?
const tsConstruct = `${year}-${month}-${date}T${hour}:${min}:00${tzOffset}`;
const epochDate = Date.parse(tsConstruct);
scheduledTs = new Date(epochDate).toISOString();