I have a time stamp like
2021-03-12T14:55:35.454Z
I want to convert that into normal time like this (below) in the ts file
2:55pm
I am working in angular. Please help if you guys know. I have tried searching other stackoverflow questions but I couldn’t find the exact solution
Please help if you guys know
Advertisement
Answer
Use, Angular’s built-in DatePipe.
if you want to use it in html
{{ yourDate| date: 'shortTime'}}
or in component file:
const myDate = new DatePipe('en-US').transform(rawDate,'shortTime' );
rawDate is your complex timestamp.
to know more about formats available , head on to https://angular.io/api/common/DatePipe