0

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>

2 Answers 2

3

Try this angular filter:

<td>{{ action.Date | date: 'd-MMM-y' }}</td>
Sign up to request clarification or add additional context in comments.

Comments

0

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>

2 Comments

thank you so much for the efforts its same as asnwered by the Bill P
The code is for Angular 2+. The template is for AngularJS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.