To convert Australian Central Time (ACST) to GMT (Greenwich Mean Time), you can use the Moment.js library in JavaScript.
Assuming you have a date and time in ACST timezone, you can create a Moment.js object and then use the .utc()
method to convert it to UTC timezone, which is equivalent to GMT.
Here's an example code snippet:
index.tsx413 chars13 lines
In this example, we first define the datetime string in ACST timezone. Then we create a Moment.js object with the moment.tz()
function, specifying the datetime string and 'Australia/Adelaide' timezone. This creates a Moment.js object with the ACST datetime.
We then use the .utc()
method on the Moment.js object, which converts it to the equivalent UTC datetime. We then get the GMT datetime string using the .format()
method with the 'YYYY-MM-DD HH:mm:ss' format.
Note that this solution requires Moment.js and its timezone plugin. You can install them using npm:
35 chars2 lines
and then import them in your JavaScript file:
index.tsx62 chars3 lines
gistlibby LogSnag