Date format

Asked

Viewed 34 times

1

I need to format date to present on the grid, but I don’t know the best way to do this.

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 the HTML that mounts the grid, I have a Tg tag with ng-repeat to take the data and put inside the td tag:

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

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

  • I recommend using Jquery Mask, bring everything right to you the fields, try there that makes life much easier. There are several types beyond date. Link: http://vinteum.com/jquery-mask-mascaras-para-campos-html-utilizando-jquery/

1 answer

0


I think it’s best to format it on the grid (HTML), if you want something more personalized, create a directive.

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

Upshot:

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

Reference: https://docs.angularjs.org/api/ng/filter/date:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.