Reputation: 612
I have an angular template that displays the unix timestamp, which is a number type:
<span>{{timestamp}}</span>
That displays like:
<span>1391139098314</span>
Instead of the number though, I want a nice string to display:
<span>1/30/2014 7:32:37 PM</span>
I thought it would be as easy as changing the template to what you see below, but that doesn't work.
<span>{{ new Date(timestamp).toLocaleString() }}</span>
Can someone tell me what I need to do in my template instead of what is not working, shown directly above?
Upvotes: 0
Views: 101
Reputation: 48992
Try date filter:
<span>{{timestamp | date:'M/dd/yyyy hh:mm:ss a'}}</span>
Upvotes: 2