Answer the question
In order to leave comments, you need to log in
How to change date format in array using angular?
Hello. A question. There is data in the database, I pull it out using a php request. Next, in js, I assign the array data to the variable, which I have already encoded into a json object, with the help of ng-repeat everything seems to work fine. But what if I need to change the date format? new Date($scope.test.date).toISOString(); Where can I write such a line? After all, I can’t pull out {{item[0].date}} and change the format in the angular controller. So what to do in this situation when you need to change something in the array (before or after that) we render all the data in the view?
Answer the question
In order to leave comments, you need to log in
I do this via ng-repeat
{{data_graphics.dateStart | date : 'dd.MM.yyyy HH:mm'}}
If this is not the correct option, I will wait for a comment
Where can I write such a line?
Or first bypass all the data (using angular.forEach, for example) and set the required format. Or do it already in the display itself using directives.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question