Here is an example of how to convert GMT to Australian Central Standard Time using the Moment.js library in JavaScript:
index.tsx279 chars8 lines
In this example, we first define a date and time in GMT format ('2021-07-30T18:00:00.000Z'
). We pass this string to Moment.js to create a new Moment object in UTC time. We then call the tz()
method to convert the Moment object to the desired timezone (in this case, 'Australia/Adelaide'
for the Australian Central Daylight Time zone). Finally, we call the format()
method to output the date and time in a readable format. The resulting output in this example would be '2021-07-31T04:30:00+09:30'
.
gistlibby LogSnag