To convert Pacific time to Eastern time in JavaScript, you can use the toLocaleString() method of the Date object with the timeZone option. Here's an example:
index.tsx301 chars8 linesIn this example, we create a Date object for January 1, 2022 at 12:00:00 PM Pacific time (which is 3 hours behind Eastern time). We then use the toLocaleString() method to format the date object as a string in the en-US locale and specify the 'America/New_York' timezone option to convert to Eastern time.
The output shows the date and time in Eastern time: "1/1/2022, 3:00:00 PM".
gistlibby LogSnag