I need to convert the date to 'dd/MM/yyyy h:mm:ss a'
From
Mon, 27 Dec 2021 17:32:52 GMT
To
27/12/2021 05:32:52 PM
I have tried the angular pipe but the output is wrong.
{{created_date | date: 'dd/MM/yyyy h:mm:ss a'}}
I am getting the below Output but the correct output supposed to be '27/12/2021 05:32:52 PM'
27/12/2021 11:02:52 PM
CodePudding user response:
formatDate(date, "dd-MM-y h:mm a", "en-US",'-0000');
CodePudding user response:
The 2nd parameter to DatePipe is timezone
which is undefined
by default. In such case the DatePipe
will use the end-user's local system timezone.
Since created_date
is in GMT, to get the result as 27/12/2021 05:32:52 PM
you can pass the timezone as:
{{created_date | date: 'dd/MM/yyyy h:mm:ss a' : 'GMT'}}