In my angular application I have a date string (2023-06-20T06:15:00) which I need to format and display as
06/20/2023 at 06:15PM (GMT-5)
I am using Angular Datepipe like below and it displays, Tue Jun 20 2023 00:00:00 GMT-0500 (Central Daylight Time)
new Date( this.datePipe.transform( new Date(2023-06-20T06:15:00), 'MMMM d, y, h:mm:ss a z' ) )
I am using other method toLocaleString and it displays , 06/20/2023, 05:00:00 AM UTC
public converDate(st:string) : string { const date = new Date(st); return date.toLocaleString('en-US', { timeZone: 'GMT', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', timeZoneName: 'short', }); }
In the first method I am getting extra text (Central Daylight Time) and also Day of the week and no comma between month,day,year In the second method, I am almost there, but want to replace UTC with GMT-5. I heard UTC and GMT-5 denotes same time. Also is there a possibility of adding 'at' before time. Can this be done.