In order to convert GMT to Australian Eastern Time in JavaScript, you can use the toLocaleString()
method of the Date
object. Here is an example:
index.tsx274 chars10 lines
In the code above, we create a Date
object with a GMT time of January 1st, 2021 at midnight. We then use the toLocaleString()
method with the en-AU
locale and the Australia/Sydney
timezone to convert the GMT time to Australian Eastern Time. The result is a string in the format of "1/1/2021, 11:00:00 AM".
gistlibby LogSnag