After doing a lot of searching, I am finally writing this.
I am trying to send a ISO-8601 formatted string from my front end to backend node rest API. So the thing is I want to parse the sent string into a UTC datetime object for further use and persisting in a database.
The question is how do I parse a ISO-8601 string correctly to a UTC datetime object ignoring the client timezone and server timezone with UTC.
I have tried this but its showing me the following -
// String sent from client side
const iso8601 = new Date().toISOString();
const nums = iso8601.match(/\d+/g).map(Number);
const utcDate = new Date(nums[0], --nums[1], nums[2], nums[3], nums[4], nums[5], nums[6]);
console.log(utcDate);