Date format

1

I need to format date to display on the grid, but I do not know the best way to do that.

I'm doing it this way:

$scope.formato[x].dataFormatada = formatDate($scope.consultas[x].data);

function formatDate(date){
    var day = date.getDate();
    var month = date.getMonth() + 1;
    var year =  date.getFullYear();

    date = day + "/" + month + "/" + date.getFullYear();
    return date;
}

In HTML that mounts the grid, I have a tg tag with ng-repeat to get the data and put it inside the td tag:

<td>{{consulta.dataFormatada}}</td>

And I have another question too ... how do I not send this $ scope.consulta.dataFormatada in a request? I used $ delete, but then the data disappears from the grid.

    
asked by anonymous 29.04.2017 / 02:53

1 answer

0

I think it's better to format it in the grid (HTML), if you want something more custom create a directive.

<span ng-non-bindable>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}</span>

Result:

2010-10-29 01:40:23 -0200

Reference: link :

    
29.04.2017 / 03:13