Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 iso date format

Tags:

angular

How can I format the ISO date into correct format? The date format return from the server side is like: 2016-12-28T11:44:00Z.

Here is my html:

<tr *ngFor="#ticket of tickets">
   <td>{{ticket.id}}</td>
    <td>{{ticket.subject}}</td>
    <td>{{ticket.status}}</td>
    <td>{{ticket.created_at}}</td>
    <td>{{ticket.updated_at}}</td>
    <td><a [routerLink]="['SingleTicket', {'id': ticket.id}]" class="btn btn-outline-primary">View</a></td>
</tr>

And here is the ticket interface.

export interface Ticket {
    id: number,
    subject: string,
    description: string,
    status: string,
    submitter: number,
    created_at: Date,
    updated_at: Date
}
like image 681
J.L Avatar asked Jan 04 '23 20:01

J.L


1 Answers

Have you tried with PIPE? .. (old Angular 1 filter) .. something like:

<td>{{ticket.created_at | date: 'dd/MM/yyyy' }}</td>
like image 99
federico scamuzzi Avatar answered Jan 22 '23 05:01

federico scamuzzi