convert australian eastern time to gmt in typescript

To convert Australian Eastern Time (AEST) to Greenwich Mean Time (GMT) in TypeScript, you can use the JavaScript Date object and some timezone conversion libraries. Here's an example function that takes an AEST string (in the format of "yyyy-mm-ddThh:mm:ss" with the timezone offset) and returns a GMT string (in the same format):

index.ts
import * as moment from 'moment-timezone';

function convertAESTtoGMT(aest: string): string {
  const aestMoment = moment(aest).tz('Australia/Sydney'); // create moment object in AEST timezone
  const gmtMoment = aestMoment.clone().tz('Etc/GMT'); // convert to GMT timezone
  return gmtMoment.format('YYYY-MM-DDTHH:mm:ss'); // return string in same format
}
358 chars
8 lines

In this example, we use the moment-timezone library to create moment objects in the AEST and GMT timezones, and then return the formatted string in the same format. You may need to adjust the timezone names and format string to match your specific use case.

gistlibby LogSnag