convert australian central daylight time to gmt in javascript

To convert Australian Central Daylight Time to GMT in JavaScript, you can use the Moment.js library. Here is an example code block that demonstrates how to do this:

index.tsx
// Create a moment object with the Australian Central Daylight Time
let acdtTime = moment.tz("2022-05-10 14:30:00", "Australia/Adelaide");

// Convert the moment object to GMT timezone
let gmtTime = acdtTime.tz("GMT");

// Get the formatted time
let formattedTime = gmtTime.format("YYYY-MM-DD HH:mm:ss");

console.log(formattedTime); // outputs "2022-05-10 04:00:00"
367 chars
11 lines

In this code block, we create a moment object with the ACDT time "2022-05-10 14:30:00" for Adelaide region, and then we convert it to the GMT timezone using the .tz() method. Finally, we format the time object using the .format() method and get the desired result.

gistlibby LogSnag