-1

I need to format my time field:

<span> {{reportBuilderObj.creationTimestamp  }}</span>

The output is:

2020-10-15T06:10:07.861+00:00

I tried to do it using below code, but it's not working either:

 <span> {{reportBuilderObj.creationTimestamp | filer : 'dd/mm/yyyy '}}</span>

I need to do below format to be:

2020-10-15

Vega
  • 27,856
  • 27
  • 95
  • 103
kumara
  • 877
  • 4
  • 19
  • 43

2 Answers2

1

Just use the date pipe:

{{ timestamp | date:'yyyy-MM-dd' }}

See this working DEMO, using the values 1602845780824 as number and 2020-10-15T06:10:07.861+00:00 as string.

Asaf
  • 1,446
  • 9
  • 17
0

I would like to suggest you to use moment. Using moment you can easily perform any date and time operation

I.E

moment('2020-10-15T06:10:07.861+00:00').format('yyyy-MM-dd')

see moment

  • @price if u can do this without moment, big help – kumara Oct 16 '20 at 11:05
  • @gihankumara you can use angular default date pipe for formatting. please have a look on following link https://stackblitz.com/edit/angular-ivy-achs53?file=src%2Fapp%2Fapp.component.html – prince boghara Oct 16 '20 at 11:11