Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ng-repeat date formatting

I am using angular ng-repeat to display an array of data including some columns which are dates but what is the best way to format the dates so they are presentable to the user? Thank you in advance.

DATES LOOK LIKE THIS IN VIEW 2016-01-14T08:00:00.000Z

WANT THIS FORMAT January 14, 2016

<td width="65%" class="joinedDate">{{user.created_at}}</td>
like image 793
sstrick Avatar asked Jul 04 '26 22:07

sstrick


2 Answers

if you format like your date (January 14, 2016) you can use

<td width="65%" class="joinedDate">{{user.created_at | date:'MMMM dd, yyyy'  }}</td>

OR

using date : 'medium' default date time like Oct 29, 2010 9:10:23 AM

<td width="65%" class="joinedDate">{{user.created_at |date:'medium'}}</td>

for more know https://docs.angularjs.org/api/ng/filter/date

like image 54
Vipin Jain Avatar answered Jul 06 '26 14:07

Vipin Jain


You can use date filter

Try like this

<td width="65%" class="joinedDate">{{user.created_at | date:'MMM dd, yyyy'  }}</td>

DEMO

like image 32
Anik Islam Abhi Avatar answered Jul 06 '26 12:07

Anik Islam Abhi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!