To convert Australian Eastern Daylight Time (AEDT) to Greenwich Mean Time (GMT) using JavaScript, you can use the built-in Date
object and its associated methods.
First, you need to create a Date
object with the AEDT time you want to convert. This can be done using the new Date()
constructor and specifying the year, month, day, hour, minute, and second in the local AEDT timezone.
index.tsx136 chars3 lines
Next, you can use the getTimezoneOffset()
method to get the difference in minutes between the local timezone (AEDT) and UTC/GMT.
index.tsx153 chars3 lines
Finally, you can use the setMinutes()
method to subtract the offset from the Date
object's minutes value, effectively converting it to GMT.
index.tsx167 chars3 lines
Now aedtDate
contains the equivalent GMT date and time. Note that this conversion assumes that AEDT is 11 hours ahead of GMT and does not account for any Daylight Saving Time (DST) changes.
gistlibby LogSnag