I need to format a date in an angular application so I use the Date Pipe: I am trying so many custom filter.
I used:
<div class="id_text">{{ splitDate(row?.created_at) | date:'dd-MM-y'}}</div>
splitDate(date) {
const data = date.split(' ');
return data[0];
}
I Used Angular Filter
<div class="id_text">{{row?.created_at | date:'dd/MM/yyyy'}}</div>
But still getting same error somewhere date does not display I need only date
Response:-
This is because
created_at
has invalid date string and angular pipe not recognizing it.All you need to replace this
25-09-2020 11:04:16
with this2020/2/25 11:04:16
, you can do it by writing a date parser method.Use date parse in template