user6010254
user6010254

Reputation:

How can I get the date format in Angular 2?

I'm in a server application comes date 12/07/2016 15:45:39

Now how do I get this format and template output 12.07.2016?

Markup

<div *ngFor="let data of item">
   <p>{{data.created_at}}</p>
</div>

showing format
2016-12-07 15:45:39

and how to filter to get 2016-12-07 in template?

Upvotes: 2

Views: 487

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136194

You could use DatePipe with y.M.d format.

<div *ngFor="let data of item">
   <p>{{data.created_at | date: 'y.M.d'}}</p>
</div>

Demo Plunker

Upvotes: 2

Related Questions