Reputation: 186
i am getting date with time but i want to remove the time and make the format as 16-oct-2019 instead of 16-10-2019T 00:00:00
<tr ng-repeat="action in Action">
<td>{{ $index + 1 }}</td>
<td id="Td1" runat="server" visible="false">{{action.sId}}</td>
<td>{{action.A}}</td>
<td>{{action.B}}</td>
<td>{{action.C}}</td>
<td>{{action.D}}</td>
<td>{{(action.Date)}}</td>
</tr>
Upvotes: 0
Views: 58
Reputation: 837
I have created one Pipe for Data Format :
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
const DATE_FORMATE = 'dd-MMM-yyyy';
@Pipe({
name: 'dateFormat'
})
export class DateFormatPipe extends DatePipe implements PipeTransform {
transform(value: string, args?: any): any {
const onlyDateValue = value.split('T')[0];
return super.transform(onlyDateValue, DATE_FORMATE);
}
}
in the template:
<tr ng-repeat="action in Action">
<td>{{ $index + 1 }}</td>
<td id="Td1" runat="server" visible="false">{{action.sId}}</td>
<td>{{action.A}}</td>
<td>{{action.B}}</td>
<td>{{action.C}}</td>
<td>{{action.D}}</td>
<td>{{(action.Date) | dateFormat }}</td>
</tr>
Upvotes: 0
Reputation: 3616
Try this angular filter:
<td>{{ action.Date | date: 'd-MMM-y' }}</td>
Upvotes: 3