To convert Australian Central Standard Time (ACST) to Greenwich Mean Time (GMT) in JavaScript, you should use the getTimezoneOffset()
method of the Date
object, which returns the difference between the local time zone and UTC time zone, in minutes.
Here's an example code snippet that converts the current date and time from ACST to GMT:
index.tsx452 chars15 lines
In this code snippet, we first create a new Date
object with the current time. Then we use the getTimezoneOffset()
method to get the timezone offset in minutes. We divide the offset by 60 to convert it to hours, and then subtract it from the current time to get the UTC time.
Finally, we log the UTC time using the toUTCString()
method.
gistlibby LogSnag