I
I
Ivan Damaskin2016-04-22 02:01:57
JavaScript
Ivan Damaskin, 2016-04-22 02:01:57

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

3 answer(s)
M
Medgat, 2016-04-22
@Medgat

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

S
Sergey, 2016-04-22
Protko @Fesor

Where can I write such a line?

where you get the data. When deserializing a response from a server.

A
Alexander Kosarev, 2016-04-22
@jaxtr

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 question

Ask a Question

731 491 924 answers to any question