Utilizing the react-datePicker
library requires using new Date()
as input. I need to save the user's selected date, time, and timezone in such a way that regardless of their location, they will see Feb 10 2024 02:00 BST
in the Date Object.
Currently, using
new Date("2024-02-10T03:00:00.000Z")
returns Sat Feb 10 2024 08:30:00 GMT+0530 (India Standard Time)
. My goal is to have it displayed as `Sat Feb 10 2024 08:30:00 GMT+0100 (British Summer Time).
I've already attempted:
const tzname = "Europe/London";
const longOffsetFormatter = new Intl.DateTimeFormat("en-US", {timeZone: tzname ,timeZoneName: "longOffset"});
const longOffsetString = longOffsetFormatter.format(new Date("2024-02-10T03:00:00.000"));
Although Moment.js could solve this issue, it is considered legacy and not recommended for use. How can I store the Date according to the provided timezone rather than the local timezone?