Agon Fejza
Agon Fejza

Reputation: 63

Angular 2 - GET date

I'm displaying date in my template:

<p>Datum</p>
<b>{{data.wageStatement?.date}}

This is how it's rendered:

2017-03-08T13:00:03.114Z

But I want to show only the date in this format:

2017-03-08

Upvotes: 1

Views: 1165

Answers (2)

morteza4818
morteza4818

Reputation: 21

i use current time and date pipe in app:

  birthday:any=new Date();
constructor(){
  this.birthday=Date.now();
}

-- and in template

<div>
 {{birthday | date}}
</div>

Upvotes: 2

Stefan Svrkota
Stefan Svrkota

Reputation: 50643

Use DatePipe:

<p>Datum</p>
{{data.wageStatement?.date | date: 'dd-MM-yyyy' }}

You can find more info about DatePipe on Angular's official docs page.

Upvotes: 2

Related Questions