Yaroslav  Osetrov Yaroslav Osetrov - 17 days ago 7
AngularJS Question

AngularJS. Convert tag value (Unix time to human-readable time)

I am getting data from a database and displaying it:

<ul>
<li ng-repeat="item in items>
<mydate>{{item.date}}</mydate>
</li>
</ul>


Where
{{item.date}}
is a Unix date such as 1374843600. How can I set the date format using AngularJS directives? Is it possible?

When I tried to do it, I was getting a value of tag mydate -
{{item.date}}

Answer

Use format date filter like this:

<mydate>{{item.date | date:'yyyy-MM-dd HH:mm:ss Z'}}</mydate>

Reference

Comments