convert alaska time to gmt in javascript

To convert Alaska time to GMT in JavaScript, you can use Moment.js library. Here's an example code snippet:

index.tsx
// Set Alaska Timezone
const alaskaTime = moment.tz("America/Anchorage");

// Convert to GMT
const gmtTime = alaskaTime.clone().tz("GMT");

// Print both in console
console.log(alaskaTime.format());
console.log(gmtTime.format());
230 chars
10 lines

In the above example, we first set the timezone to Alaska timezone using Moment.js. Then, we clone the moment object and set the timezone to "GMT". Finally, we print the formatted datetime for both the timezones in console.

gistlibby LogSnag