Hello I have a function which converts a local time to UTC using the local timezone and date:
this.conversion.dateTimeToTime('2022-07-04 12:30', 'America/Los_Angeles');
public dateTimeToTime(date, timezone = 'UTC') {
date = new Date(date);
return date.toLocaleTimeString('en-GB', {timeZone: timezone, hour12: false});
}
}
this is 12:30 local to UTC which should be 20:30(ish) but the output is 4:30utc instead going backwards
I am wondering what I am doing wrong
Thanks