After numerous attempts to format the data, I still couldn't achieve the desired outcome in my Angular App where I am dealing with data from a database. The data looks like this:
PacificTime TimeZoneCode TimeZone
2022-02-16 14:00:00.000 US/Eastern ET
Using Kendo format, I managed to convert the time to local time based on the timezone, resulting in: Wed Feb 16 2022 17:00:00 GMT-0500 (EST). However, when applying the date pipe, it always reverts back to the original time. I attempted different formats such as date: 'dd/MM/yyyy hh:mm a' to get '02/16/2022, 05:00 PM', but none of them seemed to work correctly. Can you please pinpoint what went wrong - the time format or the timezone conversion? Below is the code snippet for converting with Kendo.
convertTest(dateTime: string, zone: string) {
const from = new Date(dateTime);
const to = ZonedDate.fromLocalDate(from, zone);
return to;
}
In the HTML template:
{{convertTimezone(dataItem.pacificTime, dataItem.TimeZoneCode) | date: 'dd/MM/yyyy hh:mm a' }}
Thank you in advance.