To convert Eastern Time to GMT in JavaScript, you can use the toLocaleString() method of the Date object along with the timeZone parameter.
Here's an example code snippet:
index.tsx286 chars7 linesIn the above example, currentDate is the current date and time in the local timezone of the user's browser. We then use the toLocaleString() method to format the date and time string with the timeZone parameter set to 'America/New_York' for Eastern Time and 'GMT' for GMT. This returns the date and time in the respective timezones as formatted strings, which we log to the console.
Note that you can replace currentDate with any valid Date object to convert any date and time from Eastern Time to GMT.
gistlibby LogSnag