Reputation: 1497
I'm trying to convert a timestamp
to a date format using Angular pipes. I wrote this in the HTML template:
{{myTimestamp | date}}
Where myTimestamp
is of type number.
I get unexpected results, for example, the timestamp 1468251287
(Which matches Nov 7, 2016) is displayed as Jan 18, 1970
.
I would like to know how I can fix this issue.
Upvotes: 57
Views: 85732
Reputation: 11
So if your looking to change timestamp
to specific date then try this:
Date(user.dob).toLocaleDateString('en-GB')
Upvotes: 1
Reputation: 517
I used:
<div>{{score.timestamp | date:'dd/MM/yyyy'}}</div>
More info in https://angular.io/api/common/DatePipe
Upvotes: 17